2023-09-28 15:38:18 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-12-26 14:45:41 +08:00
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/rtsssimulation/entity"
|
2023-12-27 09:57:56 +08:00
|
|
|
"joylink.club/rtsssimulation/fi"
|
2023-12-26 14:45:41 +08:00
|
|
|
"joylink.club/rtsssimulation/repository/model/proto"
|
|
|
|
"joylink.club/rtsssimulation/sys"
|
2023-10-09 18:07:39 +08:00
|
|
|
"time"
|
2023-10-09 14:24:53 +08:00
|
|
|
|
2023-09-28 15:38:18 +08:00
|
|
|
rtss_simulation "joylink.club/rtsssimulation"
|
|
|
|
"joylink.club/rtsssimulation/repository"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-12-26 14:45:41 +08:00
|
|
|
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})
|
|
|
|
//
|
2023-12-27 13:35:33 +08:00
|
|
|
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})
|
|
|
|
//
|
2023-12-26 14:45:41 +08:00
|
|
|
repo, _ := repository.BuildRepository(protoRepo)
|
|
|
|
sim, _ := newIscsSimulation(repo)
|
|
|
|
sim.StartUp()
|
2023-12-27 09:57:56 +08:00
|
|
|
time.Sleep(2 * time.Second)
|
2023-12-27 13:35:33 +08:00
|
|
|
fi.ValveOperate(sim, "valve1", 100)
|
|
|
|
time.Sleep(5 * time.Second)
|
|
|
|
fi.ValveOperate(sim, "valve1", 1)
|
|
|
|
time.Sleep(4 * time.Second)
|
2023-12-26 14:45:41 +08:00
|
|
|
sim.Close()
|
|
|
|
time.Sleep(2 * time.Second)
|
|
|
|
}
|
|
|
|
func newIscsSimulation(repo *repository.Repository) (ecs.World, error) {
|
|
|
|
w := ecs.NewWorld(100)
|
2023-12-27 11:28:34 +08:00
|
|
|
sys.BindSystem(w)
|
2023-12-26 14:45:41 +08:00
|
|
|
//
|
|
|
|
// 初始化世界数据单例组件
|
|
|
|
entity.LoadWorldData(w, repo)
|
|
|
|
err := entity.LoadIscs(w)
|
|
|
|
return w, err
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
func main1() {
|
2023-10-31 11:31:13 +08:00
|
|
|
sim, _ := rtss_simulation.NewSimulation(&repository.Repository{})
|
2023-10-09 14:24:53 +08:00
|
|
|
sim.StartUp()
|
2023-10-09 18:07:39 +08:00
|
|
|
sim.SetSpeed(2)
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
sim.Close()
|
|
|
|
time.Sleep(2 * time.Second)
|
2023-09-28 15:38:18 +08:00
|
|
|
}
|