60 lines
2.0 KiB
Go
60 lines
2.0 KiB
Go
package main
|
|
|
|
import (
|
|
"joylink.club/ecs"
|
|
"joylink.club/rtsssimulation/entity"
|
|
"joylink.club/rtsssimulation/fi"
|
|
"joylink.club/rtsssimulation/repository/model/proto"
|
|
"joylink.club/rtsssimulation/sys"
|
|
"time"
|
|
|
|
rtss_simulation "joylink.club/rtsssimulation"
|
|
"joylink.club/rtsssimulation/repository"
|
|
)
|
|
|
|
func main() {
|
|
protoRepo := &proto.Repository{}
|
|
protoRepo.Id = "1"
|
|
protoRepo.Version = "V1"
|
|
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan1", FanType: proto.Fan_CommonFan})
|
|
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan2", FanType: proto.Fan_FcBypassFan})
|
|
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan3", FanType: proto.Fan_SoftStartFan})
|
|
protoRepo.Fans = append(protoRepo.Fans, &proto.Fan{Id: "fan4", FanType: proto.Fan_HighLowSpeedFan})
|
|
//
|
|
protoRepo.Valves = append(protoRepo.Valves, &proto.Valve{Id: "valve1", ValveType: proto.Valve_ElectricControlValve})
|
|
protoRepo.Valves = append(protoRepo.Valves, &proto.Valve{Id: "valve2", ValveType: proto.Valve_ElectricAirValve})
|
|
protoRepo.Valves = append(protoRepo.Valves, &proto.Valve{Id: "valve3", ValveType: proto.Valve_CombinationAirValve})
|
|
protoRepo.Valves = append(protoRepo.Valves, &proto.Valve{Id: "valve4", ValveType: proto.Valve_ElectricButterflyValve})
|
|
//
|
|
repo, _ := repository.BuildRepository(protoRepo)
|
|
sim, _ := newIscsSimulation(repo)
|
|
sim.StartUp()
|
|
time.Sleep(2 * time.Second)
|
|
fi.ValveOperate(sim, "valve1", 100)
|
|
time.Sleep(5 * time.Second)
|
|
fi.ValveOperate(sim, "valve1", 1)
|
|
time.Sleep(4 * time.Second)
|
|
sim.Close()
|
|
time.Sleep(2 * time.Second)
|
|
}
|
|
func newIscsSimulation(repo *repository.Repository) (ecs.World, error) {
|
|
w := ecs.NewWorld(100)
|
|
sys.BindSystem(w)
|
|
//
|
|
// 初始化世界数据单例组件
|
|
entity.LoadWorldData(w, repo)
|
|
err := entity.LoadIscs(w)
|
|
return w, err
|
|
}
|
|
|
|
///////////////////////////////////////////////////////
|
|
|
|
func main1() {
|
|
sim, _ := rtss_simulation.NewSimulation(&repository.Repository{})
|
|
sim.StartUp()
|
|
sim.SetSpeed(2)
|
|
time.Sleep(1 * time.Second)
|
|
sim.Close()
|
|
time.Sleep(2 * time.Second)
|
|
}
|