diff --git a/fi/section.go b/fi/section.go new file mode 100644 index 0000000..ac5f9a1 --- /dev/null +++ b/fi/section.go @@ -0,0 +1,55 @@ +package fi + +import ( + "joylink.club/ecs" + "joylink.club/rtsssimulation/component" + "joylink.club/rtsssimulation/entity" +) + +// DriveAxleSectionTrainIn 测试:计轴区段中车轴进入 +func DriveAxleSectionTrainIn(w ecs.World, axleSectionId string) { + w.Execute(func() { + wd := entity.GetWorldData(w) + sectionEntry, ok := wd.EntityMap[axleSectionId] + if ok { + rt := component.AxleSectionRuntimeType.Get(sectionEntry) + rt.Count = 1 + } + }) +} + +// DriveAxleSectionTrainOut 测试:计轴区段中车轴离开 +func DriveAxleSectionTrainOut(w ecs.World, axleSectionId string) { + w.Execute(func() { + wd := entity.GetWorldData(w) + sectionEntry, ok := wd.EntityMap[axleSectionId] + if ok { + rt := component.AxleSectionRuntimeType.Get(sectionEntry) + rt.Count = 0 + } + }) +} + +// DriveAxleSectionDrst 测试:设置计轴区段直接复位 +func DriveAxleSectionDrst(w ecs.World, axleSectionId string, drst bool) { + w.Execute(func() { + wd := entity.GetWorldData(w) + sectionEntry, ok := wd.EntityMap[axleSectionId] + if ok { + device := component.AxleSectionDeviceType.Get(sectionEntry) + device.Drst = drst + } + }) +} + +// DriveAxleSectionPdrst 测试:设置计轴区段预复位 +func DriveAxleSectionPdrst(w ecs.World, axleSectionId string, pdrst bool) { + w.Execute(func() { + wd := entity.GetWorldData(w) + sectionEntry, ok := wd.EntityMap[axleSectionId] + if ok { + device := component.AxleSectionDeviceType.Get(sectionEntry) + device.Pdrst = pdrst + } + }) +}