测试-计轴点、物理区段
This commit is contained in:
parent
ad3d83fee2
commit
b2a4bdb779
@ -8,6 +8,10 @@ const (
|
||||
Switch DeviceType = iota
|
||||
//长轨道
|
||||
Link
|
||||
//计轴点
|
||||
AxlePoint
|
||||
//物理区段
|
||||
PhysicalSection
|
||||
)
|
||||
|
||||
/////////////////////////////////////
|
||||
@ -35,6 +39,12 @@ type ISwitchModel interface {
|
||||
type ILinkModel interface {
|
||||
IDeviceModel
|
||||
}
|
||||
type IAxlePointModel interface {
|
||||
IDeviceModel
|
||||
}
|
||||
type IPhysicalSectionModel interface {
|
||||
IDeviceModel
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
|
||||
|
@ -13,6 +13,28 @@ import (
|
||||
"joylink.club/rtss/system"
|
||||
)
|
||||
|
||||
//
|
||||
//该测试例子线路结果图
|
||||
//link为长轨道,为两个相邻道岔间的轨道
|
||||
//ax为计轴点
|
||||
//dc为道岔,岔尖为A,B为岔后定位轨,B为侧向轨道
|
||||
//轨道、区段,左侧为A,右侧为B
|
||||
//
|
||||
/*
|
||||
//K0 K3000 * 100 * 10 K6070 * 100 * 10
|
||||
// link1 link2
|
||||
//ax1==================ax3=====dc1======ax5==============================ax7
|
||||
// =
|
||||
// =
|
||||
// ax9 link5
|
||||
// =
|
||||
// =
|
||||
//ax2=============================ax4======dc2======ax6===================ax8
|
||||
// link3 link4
|
||||
//K0 K3070 * 100 * 10 K6070 * 100 * 10
|
||||
*/
|
||||
//
|
||||
//
|
||||
func init() {
|
||||
log.SetFlags(log.Lshortfile | log.Lmicroseconds | log.Ldate)
|
||||
}
|
||||
@ -61,7 +83,9 @@ func initMemoryModel(world ecs.World) {
|
||||
//simulation.ComSimMemory.SetValue(memoryEntry, *simulation.NewSimMemory())
|
||||
simMemory := simulation.NewSimMemory()
|
||||
simulation.ComSimMemory.Set(memoryEntry, simMemory)
|
||||
createModelsRelation(simMemory)
|
||||
createSkeletonModelsRelation(simMemory)
|
||||
createKilometerSignModelsRelation(simMemory)
|
||||
createPhsicalSectionModelsRelation(simMemory)
|
||||
}
|
||||
|
||||
// 初始化道岔状态
|
||||
@ -91,8 +115,8 @@ func initTrainState(world ecs.World, trainId string, linkLocation iwayside.LinkL
|
||||
simulation.ComTrainState.Set(trainEntry, train)
|
||||
}
|
||||
|
||||
// 构建模型关系
|
||||
func createModelsRelation(memory *simulation.SimMemory) {
|
||||
// 固定关系:构建骨架模型关系,即长link与道岔的连接关系
|
||||
func createSkeletonModelsRelation(memory *simulation.SimMemory) {
|
||||
//
|
||||
link1Model := &mwayside.LinkModel{DeviceModel: mwayside.DeviceModel{Id: "link1", Type: iwayside.Link}, Len: 3000 * 100 * 10}
|
||||
link2Model := &mwayside.LinkModel{DeviceModel: mwayside.DeviceModel{Id: "link2", Type: iwayside.Link}, Len: 3070 * 100 * 10}
|
||||
@ -105,8 +129,8 @@ func createModelsRelation(memory *simulation.SimMemory) {
|
||||
memory.Links[link4Model.Id] = link4Model
|
||||
memory.Links[link5Model.Id] = link5Model
|
||||
//
|
||||
switch1Model := &mwayside.SwitchModel{DeviceModel: mwayside.DeviceModel{Id: "dc1", Type: iwayside.Switch}}
|
||||
switch2Model := &mwayside.SwitchModel{DeviceModel: mwayside.DeviceModel{Id: "dc2", Type: iwayside.Switch}}
|
||||
switch1Model := &mwayside.SwitchModel{DeviceModel: mwayside.DeviceModel{Id: "dc1", Type: iwayside.Switch}, KilometerSign: 3000 * 100 * 10}
|
||||
switch2Model := &mwayside.SwitchModel{DeviceModel: mwayside.DeviceModel{Id: "dc2", Type: iwayside.Switch}, KilometerSign: 3070 * 100 * 10}
|
||||
memory.Switchs[switch1Model.Id] = switch1Model
|
||||
memory.Switchs[switch2Model.Id] = switch2Model
|
||||
//
|
||||
@ -125,3 +149,76 @@ func createModelsRelation(memory *simulation.SimMemory) {
|
||||
switch2Model.PortB = &mwayside.LinkRef{Port: iwayside.B, Link: link3Model}
|
||||
switch2Model.PortC = &mwayside.LinkRef{Port: iwayside.B, Link: link5Model}
|
||||
}
|
||||
|
||||
//
|
||||
/*
|
||||
//K0 K3000 * 100 * 10 K6070 * 100 * 10
|
||||
// link1 link2
|
||||
//ax1==================ax3=====dc1======ax5==============================ax7
|
||||
// =
|
||||
// =
|
||||
// ax9 link5
|
||||
// =
|
||||
// =
|
||||
//ax2=============================ax4======dc2======ax6===================ax8
|
||||
// link3 link4
|
||||
//K0 K3070 * 100 * 10 K6070 * 100 * 10
|
||||
*/
|
||||
//
|
||||
//
|
||||
//固定关系:构建物理区段关系
|
||||
func createPhsicalSectionModelsRelation(memory *simulation.SimMemory) {
|
||||
ax1 := memory.AxlePoints["ax1"]
|
||||
ax2 := memory.AxlePoints["ax2"]
|
||||
ax3 := memory.AxlePoints["ax3"]
|
||||
ax4 := memory.AxlePoints["ax4"]
|
||||
ax5 := memory.AxlePoints["ax5"]
|
||||
ax6 := memory.AxlePoints["ax6"]
|
||||
ax7 := memory.AxlePoints["ax7"]
|
||||
ax8 := memory.AxlePoints["ax8"]
|
||||
ax9 := memory.AxlePoints["ax9"]
|
||||
//
|
||||
ph13 := mwayside.NewLinePhysicalSectionModel("ph13", ax1, ax3)
|
||||
ph359 := mwayside.NewAreaPhysicalSectionModel("ph359", ax3, ax5, ax9)
|
||||
ph57 := mwayside.NewLinePhysicalSectionModel("ph57", ax5, ax7)
|
||||
ph24 := mwayside.NewLinePhysicalSectionModel("ph24", ax2, ax4)
|
||||
ph469 := mwayside.NewAreaPhysicalSectionModel("ph469", ax4, ax6, ax9)
|
||||
ph68 := mwayside.NewLinePhysicalSectionModel("ph68", ax6, ax8)
|
||||
//
|
||||
memory.PhysicalSections[ph13.Id] = ph13
|
||||
memory.PhysicalSections[ph359.Id] = ph359
|
||||
memory.PhysicalSections[ph57.Id] = ph57
|
||||
memory.PhysicalSections[ph24.Id] = ph24
|
||||
memory.PhysicalSections[ph469.Id] = ph469
|
||||
memory.PhysicalSections[ph68.Id] = ph68
|
||||
}
|
||||
|
||||
// 固定关系:构建坐标设备与骨架模型的关系
|
||||
func createKilometerSignModelsRelation(memory *simulation.SimMemory) {
|
||||
link1 := memory.Links["link1"]
|
||||
link2 := memory.Links["link2"]
|
||||
link3 := memory.Links["link3"]
|
||||
link4 := memory.Links["link4"]
|
||||
link5 := memory.Links["link5"]
|
||||
//
|
||||
ax1 := mwayside.NewAxlePointModel("ax1", link1, 0)
|
||||
ax2 := mwayside.NewAxlePointModel("ax2", link3, 0)
|
||||
ax3 := mwayside.NewAxlePointModel("ax3", link1, 3000*100*10-20*100*10)
|
||||
ax4 := mwayside.NewAxlePointModel("ax4", link3, 3070*100*10-20*100*10)
|
||||
ax5 := mwayside.NewAxlePointModel("ax5", link2, 3000*100*10+20*100*10)
|
||||
ax6 := mwayside.NewAxlePointModel("ax6", link4, 3070*100*10+20*100*10)
|
||||
ax7 := mwayside.NewAxlePointModel("ax7", link2, 6070*100*10)
|
||||
ax8 := mwayside.NewAxlePointModel("ax8", link4, 6070*100*10)
|
||||
ax9 := mwayside.NewAxlePointModel("ax9", link5, 3000*100*10+35*100*10)
|
||||
//
|
||||
memory.AxlePoints[ax1.Id] = ax1
|
||||
memory.AxlePoints[ax2.Id] = ax2
|
||||
memory.AxlePoints[ax3.Id] = ax3
|
||||
memory.AxlePoints[ax4.Id] = ax4
|
||||
memory.AxlePoints[ax5.Id] = ax5
|
||||
memory.AxlePoints[ax6.Id] = ax6
|
||||
memory.AxlePoints[ax7.Id] = ax7
|
||||
memory.AxlePoints[ax8.Id] = ax8
|
||||
memory.AxlePoints[ax9.Id] = ax9
|
||||
//
|
||||
}
|
||||
|
20
examples/rtss-cg/mwayside/axle_point_model.go
Normal file
20
examples/rtss-cg/mwayside/axle_point_model.go
Normal file
@ -0,0 +1,20 @@
|
||||
package mwayside
|
||||
|
||||
import "joylink.club/rtss/iwayside"
|
||||
|
||||
//计轴检测点模型
|
||||
type AxlePointModel struct {
|
||||
DeviceModel
|
||||
//计轴点公里标,单位mm
|
||||
KilometerSign int64
|
||||
//所在轨道
|
||||
Link iwayside.ILinkModel
|
||||
}
|
||||
|
||||
func NewAxlePointModel(id string, link iwayside.ILinkModel, kilometerSign int64) *AxlePointModel {
|
||||
return &AxlePointModel{
|
||||
DeviceModel: DeviceModel{Id: id, Type: iwayside.AxlePoint},
|
||||
KilometerSign: kilometerSign,
|
||||
Link: link,
|
||||
}
|
||||
}
|
35
examples/rtss-cg/mwayside/physical_section_model.go
Normal file
35
examples/rtss-cg/mwayside/physical_section_model.go
Normal file
@ -0,0 +1,35 @@
|
||||
package mwayside
|
||||
|
||||
import "joylink.club/rtss/iwayside"
|
||||
|
||||
//物理区段
|
||||
type PhysicalSectionModel struct {
|
||||
DeviceModel
|
||||
//true-线性物理区段;false-岔区物理区段
|
||||
Line bool
|
||||
//线性物理区段:A端计轴点
|
||||
AxlePointPortA iwayside.IAxlePointModel
|
||||
//线性物理区段:B端计轴点
|
||||
AxlePointPortB iwayside.IAxlePointModel
|
||||
//岔区物理区段: 计轴点集合
|
||||
AreaAxlePoints []iwayside.IAxlePointModel
|
||||
}
|
||||
|
||||
//创建线性物理区段模型
|
||||
func NewLinePhysicalSectionModel(id string, axlePointPortA iwayside.IAxlePointModel, axlePointPortB iwayside.IAxlePointModel) *PhysicalSectionModel {
|
||||
return &PhysicalSectionModel{
|
||||
DeviceModel: DeviceModel{Id: id, Type: iwayside.PhysicalSection},
|
||||
Line: true,
|
||||
AxlePointPortA: axlePointPortA,
|
||||
AxlePointPortB: axlePointPortB,
|
||||
}
|
||||
}
|
||||
|
||||
//创建岔区物理区段模型
|
||||
func NewAreaPhysicalSectionModel(id string, axlePointPorts ...iwayside.IAxlePointModel) *PhysicalSectionModel {
|
||||
return &PhysicalSectionModel{
|
||||
DeviceModel: DeviceModel{Id: id, Type: iwayside.PhysicalSection},
|
||||
Line: false,
|
||||
AreaAxlePoints: axlePointPorts,
|
||||
}
|
||||
}
|
@ -9,4 +9,6 @@ type SwitchModel struct {
|
||||
PortB *LinkRef
|
||||
//道岔C端连接的轨道
|
||||
PortC *LinkRef
|
||||
//道岔公里标,单位mm
|
||||
KilometerSign int64
|
||||
}
|
||||
|
@ -8,12 +8,19 @@ import (
|
||||
)
|
||||
|
||||
type SimMemory struct {
|
||||
Links map[string]iwayside.ILinkModel
|
||||
Switchs map[string]iwayside.ISwitchModel
|
||||
Links map[string]iwayside.ILinkModel
|
||||
Switchs map[string]iwayside.ISwitchModel
|
||||
AxlePoints map[string]iwayside.IAxlePointModel
|
||||
PhysicalSections map[string]iwayside.IPhysicalSectionModel
|
||||
}
|
||||
|
||||
func NewSimMemory() *SimMemory {
|
||||
return &SimMemory{Links: make(map[string]iwayside.ILinkModel), Switchs: make(map[string]iwayside.ISwitchModel)}
|
||||
return &SimMemory{
|
||||
Links: make(map[string]iwayside.ILinkModel),
|
||||
Switchs: make(map[string]iwayside.ISwitchModel),
|
||||
AxlePoints: make(map[string]iwayside.IAxlePointModel),
|
||||
PhysicalSections: make(map[string]iwayside.IPhysicalSectionModel),
|
||||
}
|
||||
}
|
||||
|
||||
func GetMemoryModel(world ecs.World) *SimMemory {
|
||||
|
Loading…
Reference in New Issue
Block a user