信号机2xh1测试

This commit is contained in:
xzb 2023-10-10 17:26:09 +08:00
parent f7d64c1b6b
commit dc9be681a1
2 changed files with 39 additions and 8 deletions

View File

@ -7,12 +7,19 @@ import (
"joylink.club/rtsssimulation/consts" "joylink.club/rtsssimulation/consts"
"joylink.club/rtsssimulation/entity" "joylink.club/rtsssimulation/entity"
"joylink.club/rtsssimulation/examples/signal1/sigSys" "joylink.club/rtsssimulation/examples/signal1/sigSys"
"joylink.club/rtsssimulation/fi"
"joylink.club/rtsssimulation/repository" "joylink.club/rtsssimulation/repository"
"joylink.club/rtsssimulation/repository/model/proto" "joylink.club/rtsssimulation/repository/model/proto"
"joylink.club/rtsssimulation/sys/circuit_sys" "joylink.club/rtsssimulation/sys/circuit_sys"
"joylink.club/rtsssimulation/sys/device_sys"
"log"
"time" "time"
) )
const (
IdSignal2XH1 = "signal1-2xh1"
)
// 信号机测试 // 信号机测试
func main() { func main() {
proto := &proto.Repository{} proto := &proto.Repository{}
@ -23,21 +30,41 @@ func main() {
sim := rtss_simulation.NewSimulation(repo) sim := rtss_simulation.NewSimulation(repo)
loadEntities(sim, repo) loadEntities(sim, repo)
sim.SetSpeed(0.1) sim.SetSpeed(0.1)
sim.AddSystem(circuit_sys.NewSignal2XH1System())
sim.AddSystem(sigSys.NewSignalDebugSystem()) sim.AddSystem(sigSys.NewSignalDebugSystem())
sim.AddSystem(device_sys.NewRelaySys())
sim.AddSystem(circuit_sys.NewSignal2XH1System())
sim.StartUp() sim.StartUp()
// //
time.Sleep(10 * time.Second) time.Sleep(1 * time.Second)
worldLog(sim, "===>>灭灯 .....")
fi.DriveSignal2XH1Dd(sim, IdSignal2XH1, false) //灭灯
time.Sleep(2 * time.Second)
worldLog(sim, "===>>亮灯 .....")
fi.DriveSignal2XH1Dd(sim, IdSignal2XH1, true) //亮灯
time.Sleep(2 * time.Second)
worldLog(sim, "===>>开通列车信号 .....")
fi.DriveSignal2XH1Lx(sim, IdSignal2XH1) //开通列车信号
time.Sleep(3 * time.Second)
worldLog(sim, "===>>开通禁止信号 .....")
fi.DriveSignal2XH1Non(sim, IdSignal2XH1) //开通禁止信号
//
time.Sleep(3 * time.Second)
sim.Close() sim.Close()
} }
func worldLog(w ecs.World, logInfo string) {
ecs.Request(w, func() any {
log.Println(logInfo)
return nil
})
}
func addProtoSignal2XH1(r *proto.Repository) { func addProtoSignal2XH1(r *proto.Repository) {
//相关继电器 //相关继电器
r.Relays = append(r.Relays, &proto.Relay{Id: "2xh1-ddj", Code: consts.SIGNAL_DDJ}) r.Relays = append(r.Relays, &proto.Relay{Id: "2xh1-ddj", Code: consts.SIGNAL_DDJ, Model: proto.Relay_JWXC_1700})
r.Relays = append(r.Relays, &proto.Relay{Id: "2xh1-dj", Code: consts.SIGNAL_DJ}) r.Relays = append(r.Relays, &proto.Relay{Id: "2xh1-dj", Code: consts.SIGNAL_DJ, Model: proto.Relay_JZXC_H18})
r.Relays = append(r.Relays, &proto.Relay{Id: "2xh1-lxj", Code: consts.SIGNAL_LXJ}) r.Relays = append(r.Relays, &proto.Relay{Id: "2xh1-lxj", Code: consts.SIGNAL_LXJ, Model: proto.Relay_JWXC_1700})
// //
signal := &proto.Signal{} signal := &proto.Signal{}
signal.Id = "signal1-2xh1" signal.Id = IdSignal2XH1
signal.Km = &proto.Kilometer{} signal.Km = &proto.Kilometer{}
// //
group := &proto.ElectronicComponentGroup{Code: consts.SIGNAL_2XH1, ComponentIds: []string{"2xh1-ddj", "2xh1-dj", "2xh1-lxj"}} group := &proto.ElectronicComponentGroup{Code: consts.SIGNAL_2XH1, ComponentIds: []string{"2xh1-ddj", "2xh1-dj", "2xh1-lxj"}}

View File

@ -19,8 +19,12 @@ func NewSignalDebugSystem() *SignalDebugSystem {
func (s *SignalDebugSystem) Update(w ecs.World) { func (s *SignalDebugSystem) Update(w ecs.World) {
s.query.Each(w, func(entry *ecs.Entry) { s.query.Each(w, func(entry *ecs.Entry) {
uid := component.UidType.Get(entry) uid := component.UidType.Get(entry)
//state := component.Signal2XH1ElectronicType.Get(entry) state := component.Signal2XH1ElectronicType.Get(entry)
filament := component.Signal2XH1FilamentType.Get(entry) filament := component.Signal2XH1FilamentType.Get(entry)
log.Println("===>> uid = ", uid.Id, " 绿灯 = ", filament.L, " 红灯 = ", filament.H) //
ddj := component.BitStateType.Get(state.Z2XH1_DDJ)
lxj := component.BitStateType.Get(state.Z2XH1_LXJ)
//
log.Printf("===>> uid = %s ddj = %t lxj = %t , 绿灯 = %t 红灯 = %t,\n", uid.Id, ddj.Val, lxj.Val, filament.L, filament.H)
}) })
} }