2023-11-03 17:26:32 +08:00
|
|
|
package entity
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log/slog"
|
|
|
|
|
|
|
|
"joylink.club/ecs"
|
|
|
|
"joylink.club/rtsssimulation/component"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newCiQC(w ecs.World, data *component.WorldData) *ecs.Entry {
|
|
|
|
entry := w.Entry(w.Create(component.CiQcTableType, component.CiQcStateType))
|
|
|
|
data.CiQcEntities = append(data.CiQcEntities, entry)
|
|
|
|
return entry
|
|
|
|
}
|
|
|
|
|
|
|
|
// 加载联锁驱动、采集卡
|
|
|
|
func LoadCiQC(w ecs.World) error {
|
|
|
|
data := GetWorldData(w)
|
|
|
|
for _, csr := range data.Repo.CiQcList() {
|
|
|
|
// if len(csr.CjList) == 0 {
|
|
|
|
// return fmt.Errorf("加载联锁驱采卡实体失败,车站'%s'无采集码表数据", csr.StationId)
|
|
|
|
// }
|
|
|
|
// if len(csr.QdList) == 0 {
|
|
|
|
// return fmt.Errorf("加载联锁驱采卡实体失败,车站'%s'无驱动码表数据", csr.StationId)
|
|
|
|
// }
|
2023-11-06 17:32:34 +08:00
|
|
|
// 加载联锁驱采卡实体
|
2023-11-03 17:26:32 +08:00
|
|
|
if len(csr.CjList) == 0 || len(csr.QdList) == 0 {
|
|
|
|
slog.Warn("加载联锁驱采卡实体失败,无驱动/采集码表数据", "车站", csr.StationId)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
entry := newCiQC(w, data)
|
2023-12-13 11:21:13 +08:00
|
|
|
qctable := component.NewCiQcTable(csr.StationId, csr.QdList, csr.CjList)
|
2023-11-03 17:26:32 +08:00
|
|
|
err := qctable.BuildQcIndex()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
component.CiQcTableType.Set(entry, qctable)
|
|
|
|
component.CiQcStateType.Set(entry, component.NewCiQcState(len(csr.QdList), len(csr.CjList)))
|
|
|
|
}
|
|
|
|
// TODO: 不同联锁驱动码位索引唯一检查
|
|
|
|
return nil
|
|
|
|
}
|