【新增】车库门PSL模型构建及相关ecs逻辑;

【改动】车库门ecs逻辑
This commit is contained in:
thesai 2024-03-26 13:12:16 +08:00
parent f0a6c534ec
commit d63be32ad5
19 changed files with 1371 additions and 1128 deletions

View File

@ -10,6 +10,7 @@ var (
CkmMgzTag = ecs.NewTag() //门故障tag CkmMgzTag = ecs.NewTag() //门故障tag
CkmCircuitType = ecs.NewComponentType[CkmCircuit]() CkmCircuitType = ecs.NewComponentType[CkmCircuit]()
CkmStateType = ecs.NewComponentType[component_data.CkmState]() CkmStateType = ecs.NewComponentType[component_data.CkmState]()
CkmPslType = ecs.NewComponentType[CkmPsl]()
) )
type CkmCircuit struct { type CkmCircuit struct {
@ -23,3 +24,10 @@ type CkmCircuit struct {
KMJ *ecs.Entry //开门继电器 KMJ *ecs.Entry //开门继电器
GMJ *ecs.Entry //关门继电器 GMJ *ecs.Entry //关门继电器
} }
type CkmPsl struct {
KMA *ecs.Entry //开门按钮
GMA *ecs.Entry //关门按钮
MPLA *ecs.Entry //门旁路按钮
MMSA *ecs.Entry //门模式按钮
}

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.32.0 // protoc-gen-go v1.33.0
// protoc v4.23.1 // protoc v4.23.1
// source: component/ci.proto // source: component/ci.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.32.0 // protoc-gen-go v1.33.0
// protoc v4.23.1 // protoc v4.23.1
// source: component/ckm.proto // source: component/ckm.proto
@ -26,7 +26,7 @@ type CkmState struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Close bool `protobuf:"varint,1,opt,name=close,proto3" json:"close,omitempty"` Close bool `protobuf:"varint,1,opt,name=close,proto3" json:"close,omitempty"`
Mms bool `protobuf:"varint,2,opt,name=mms,proto3" json:"mms,omitempty"` //门模式(true远程false本地 Mms bool `protobuf:"varint,2,opt,name=mms,proto3" json:"mms,omitempty"` //门模式(false远程true本地
Mgz bool `protobuf:"varint,3,opt,name=mgz,proto3" json:"mgz,omitempty"` //门故障 Mgz bool `protobuf:"varint,3,opt,name=mgz,proto3" json:"mgz,omitempty"` //门故障
// 驱动状态(没有继电器时直接操作以下状态) // 驱动状态(没有继电器时直接操作以下状态)
Km bool `protobuf:"varint,4,opt,name=km,proto3" json:"km,omitempty"` //开门 Km bool `protobuf:"varint,4,opt,name=km,proto3" json:"km,omitempty"` //开门

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.32.0 // protoc-gen-go v1.33.0
// protoc v4.23.1 // protoc v4.23.1
// source: component/common.proto // source: component/common.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.32.0 // protoc-gen-go v1.33.0
// protoc v4.23.1 // protoc v4.23.1
// source: component/equipment.proto // source: component/equipment.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.32.0 // protoc-gen-go v1.33.0
// protoc v4.23.1 // protoc v4.23.1
// source: component/points.proto // source: component/points.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.32.0 // protoc-gen-go v1.33.0
// protoc v4.23.1 // protoc v4.23.1
// source: component/psd.proto // source: component/psd.proto

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.32.0 // protoc-gen-go v1.33.0
// protoc v4.23.1 // protoc v4.23.1
// source: component/signal.proto // source: component/signal.proto

View File

@ -1,6 +1,7 @@
package entity package entity
import ( import (
"github.com/yohamta/donburi"
"joylink.club/ecs" "joylink.club/ecs"
"joylink.club/rtsssimulation/component" "joylink.club/rtsssimulation/component"
"joylink.club/rtsssimulation/repository" "joylink.club/rtsssimulation/repository"
@ -12,14 +13,31 @@ var CkmBaseComponentTypes = []ecs.IComponentType{component.UidType, component.Ck
func LoadCkm(w ecs.World) error { func LoadCkm(w ecs.World) error {
data := GetWorldData(w) data := GetWorldData(w)
for _, ckm := range data.Repo.CkmList() { for _, ckm := range data.Repo.CkmList() {
ckmEntry := buildBaseEntry(w, ckm, data)
addCkmCircuit(w, ckm, ckmEntry, data)
}
for _, psl := range data.Repo.CkmPslList() {
ckmEntry := data.EntityMap[psl.Ckm().Id()]
addCkmPsl(w, psl, ckmEntry, data)
}
return nil
}
// 构建基础镜像
func buildBaseEntry(w ecs.World, ckm *repository.Ckm, data *component.WorldData) *donburi.Entry {
//创建基础entry //创建基础entry
entry := w.Entry(w.Create(CkmBaseComponentTypes...)) entry := w.Entry(w.Create(CkmBaseComponentTypes...))
component.UidType.SetValue(entry, component.Uid{Id: ckm.Id()}) component.UidType.SetValue(entry, component.Uid{Id: ckm.Id()})
data.EntityMap[ckm.Id()] = entry data.EntityMap[ckm.Id()] = entry
return entry
}
// 添加车库门电路
func addCkmCircuit(w ecs.World, ckm *repository.Ckm, ckmEntry *donburi.Entry, data *component.WorldData) {
//加载电路 //加载电路
if len(ckm.ComponentGroups()) != 0 { if len(ckm.ComponentGroups()) != 0 {
circuit := &component.CkmCircuit{} circuit := &component.CkmCircuit{}
entry.AddComponent(component.CkmCircuitType, unsafe.Pointer(circuit)) ckmEntry.AddComponent(component.CkmCircuitType, unsafe.Pointer(circuit))
for _, group := range ckm.ComponentGroups() { for _, group := range ckm.ComponentGroups() {
for _, ec := range group.Components() { for _, ec := range group.Components() {
relay := ec.(*repository.Relay) relay := ec.(*repository.Relay)
@ -42,6 +60,15 @@ func LoadCkm(w ecs.World) error {
} }
} }
} }
} }
return nil
// 添加车库门PSL
func addCkmPsl(w ecs.World, psl *repository.CkmPsl, ckmEntry *ecs.Entry, data *component.WorldData) {
ckmPsl := component.CkmPsl{
KMA: NewButtonEntity(w, psl.Kma(), data.EntityMap),
GMA: NewButtonEntity(w, psl.Gma(), data.EntityMap),
MPLA: NewButtonEntity(w, psl.Mpla(), data.EntityMap),
MMSA: NewButtonEntity(w, psl.Mmsa(), data.EntityMap),
}
ckmEntry.AddComponent(component.CkmPslType, unsafe.Pointer(&ckmPsl))
} }

View File

@ -29,7 +29,7 @@ func LoadPsd(w ecs.World) error {
} }
func loadPlatformMkxCircuit(world ecs.World, entryMap map[string]*ecs.Entry, pmcMap map[string]*ecs.Entry, func loadPlatformMkxCircuit(world ecs.World, entryMap map[string]*ecs.Entry, pmcMap map[string]*ecs.Entry,
mkx *repository.Mkx, mkxEntry *ecs.Entry, psdEntry *ecs.Entry) { mkx *repository.PsdPsl, mkxEntry *ecs.Entry, psdEntry *ecs.Entry) {
platformMkx, ok := pmcMap[mkx.Psd().Id()] platformMkx, ok := pmcMap[mkx.Psd().Id()]
if !ok { if !ok {
platformMkx = NewPlatformMkxEntry(world, entryMap, mkx) platformMkx = NewPlatformMkxEntry(world, entryMap, mkx)
@ -103,7 +103,7 @@ func NewAsdEntry(world ecs.World, worldData *component.WorldData, psdId string,
return entry return entry
} }
func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repository.Mkx) *ecs.Entry { func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repository.PsdPsl) *ecs.Entry {
entry := world.Entry(world.Create(component.UidType, component.MkxType)) entry := world.Entry(world.Create(component.UidType, component.MkxType))
worldData.EntityMap[mkx.Id()] = entry worldData.EntityMap[mkx.Id()] = entry
component.UidType.SetValue(entry, component.Uid{Id: mkx.Id()}) component.UidType.SetValue(entry, component.Uid{Id: mkx.Id()})
@ -149,7 +149,7 @@ func NewMkxEntry(world ecs.World, worldData *component.WorldData, mkx *repositor
return entry return entry
} }
func NewPlatformMkxEntry(world ecs.World, entryMap map[string]*ecs.Entry, mkx *repository.Mkx) *ecs.Entry { func NewPlatformMkxEntry(world ecs.World, entryMap map[string]*ecs.Entry, mkx *repository.PsdPsl) *ecs.Entry {
entry := world.Entry(world.Create(component.PlatformMkxCircuitType)) entry := world.Entry(world.Create(component.PlatformMkxCircuitType))
circuit := &component.PlatformMkxCircuit{} circuit := &component.PlatformMkxCircuit{}
if pcbj := mkx.Pcbj(); pcbj != nil { if pcbj := mkx.Pcbj(); pcbj != nil {

View File

@ -6,7 +6,7 @@ option go_package = "./component/component_data";
message CkmState { message CkmState {
bool close = 1; bool close = 1;
bool mms = 2; //true远程false本地 bool mms = 2; //false远程true本地
bool mgz = 3; // bool mgz = 3; //
// //

View File

@ -30,6 +30,7 @@ message Repository {
repeated Route routes = 23; repeated Route routes = 23;
repeated Ckm ckms = 24; repeated Ckm ckms = 24;
repeated Xcj xcjs = 25; repeated Xcj xcjs = 25;
repeated CkmPsl ckmPsls = 26;
//ISCS [300,500] //ISCS [300,500]
//ISCS管线 //ISCS管线
repeated Pipe pipes = 300; repeated Pipe pipes = 300;
@ -221,8 +222,9 @@ enum DeviceType {
DeviceType_PowerScreen = 22; DeviceType_PowerScreen = 22;
// //
DeviceType_Route = 23; DeviceType_Route = 23;
DeviceType_Ckm = 24; DeviceType_Ckm = 24; //
DeviceType_Xcj = 25; DeviceType_Xcj = 25; //
DeviceType_CkmPsl = 26; //PSL
//--------ISCS [300,500]------ //--------ISCS [300,500]------
//ISCS门磁 //ISCS门磁
@ -518,6 +520,16 @@ message Mkx {
string mplaId = 18; // string mplaId = 18; //
string jxtcplaId = 19; // string jxtcplaId = 19; //
} }
//PSL
message CkmPsl {
string id= 1;
string ckmId = 2;
string gmaId = 3; //
string kmaId = 4; //
string mplaId = 5; //
string mmsaId = 6; //
}
// //
message Platform { message Platform {
enum PlatformDirection { enum PlatformDirection {

View File

@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT. // Code generated by protoc-gen-go. DO NOT EDIT.
// versions: // versions:
// protoc-gen-go v1.32.0 // protoc-gen-go v1.33.0
// protoc v4.23.1 // protoc v4.23.1
// source: cg_repo.proto // source: cg_repo.proto

34
repository/ckm_psl.go Normal file
View File

@ -0,0 +1,34 @@
package repository
import "joylink.club/rtsssimulation/repository/model/proto"
type CkmPsl struct {
Identity
ckm *Ckm
kma *Button
gma *Button
mpla *Button
mmsa *Button
}
func NewCkmPsl(id string) *CkmPsl {
return &CkmPsl{
Identity: identity{id, proto.DeviceType_DeviceType_CkmPsl},
}
}
func (psl *CkmPsl) Ckm() *Ckm {
return psl.ckm
}
func (psl *CkmPsl) Kma() *Button {
return psl.kma
}
func (psl *CkmPsl) Gma() *Button {
return psl.gma
}
func (psl *CkmPsl) Mpla() *Button {
return psl.mpla
}
func (psl *CkmPsl) Mmsa() *Button {
return psl.mmsa
}

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@ package repository
import "joylink.club/rtsssimulation/repository/model/proto" import "joylink.club/rtsssimulation/repository/model/proto"
type Mkx struct { type PsdPsl struct {
Identity Identity
psd *Psd psd *Psd
@ -25,8 +25,8 @@ type Mkx struct {
jxtcpl *Button jxtcpl *Button
} }
func NewMkx(id string) *Mkx { func NewPsdPsl(id string) *PsdPsl {
return &Mkx{ return &PsdPsl{
Identity: identity{ Identity: identity{
id: id, id: id,
deviceType: proto.DeviceType_DeviceType_Mkx, deviceType: proto.DeviceType_DeviceType_Mkx,
@ -34,74 +34,74 @@ func NewMkx(id string) *Mkx {
} }
} }
func (m *Mkx) Psd() *Psd { func (m *PsdPsl) Psd() *Psd {
return m.psd return m.psd
} }
func (m *Mkx) Pcb() *Button { func (m *PsdPsl) Pcb() *Button {
return m.pcb return m.pcb
} }
func (m *Mkx) Pcbpl() *Button { func (m *PsdPsl) Pcbpl() *Button {
return m.pcbpl return m.pcbpl
} }
func (m *Mkx) Pcbj() *Relay { func (m *PsdPsl) Pcbj() *Relay {
return m.pcbj return m.pcbj
} }
func (m *Mkx) Pob() *Button { func (m *PsdPsl) Pob() *Button {
return m.pob return m.pob
} }
func (m *Mkx) Pobpl() *Button { func (m *PsdPsl) Pobpl() *Button {
return m.pobpl return m.pobpl
} }
func (m *Mkx) Pobj() *Relay { func (m *PsdPsl) Pobj() *Relay {
return m.pobj return m.pobj
} }
func (m *Mkx) Pab() *Button { func (m *PsdPsl) Pab() *Button {
return m.pab return m.pab
} }
func (m *Mkx) Pabpl() *Button { func (m *PsdPsl) Pabpl() *Button {
return m.pabpl return m.pabpl
} }
func (m *Mkx) Pabj() *Relay { func (m *PsdPsl) Pabj() *Relay {
return m.pabj return m.pabj
} }
func (m *Mkx) Wrzf() *Button { func (m *PsdPsl) Wrzf() *Button {
return m.wrzf return m.wrzf
} }
func (m *Mkx) Wrzfpl() *Button { func (m *PsdPsl) Wrzfpl() *Button {
return m.wrzfpl return m.wrzfpl
} }
func (m *Mkx) Wrzfj() *Relay { func (m *PsdPsl) Wrzfj() *Relay {
return m.wrzfj return m.wrzfj
} }
func (m *Mkx) Qkqr() *Button { func (m *PsdPsl) Qkqr() *Button {
return m.qkqr return m.qkqr
} }
func (m *Mkx) Qkqrpl() *Button { func (m *PsdPsl) Qkqrpl() *Button {
return m.qkqrpl return m.qkqrpl
} }
func (m *Mkx) Qkqrj() *Relay { func (m *PsdPsl) Qkqrj() *Relay {
return m.qkqrj return m.qkqrj
} }
func (m *Mkx) Mpl() *Button { func (m *PsdPsl) Mpl() *Button {
return m.mpl return m.mpl
} }
func (m *Mkx) Jxtcpl() *Button { func (m *PsdPsl) Jxtcpl() *Button {
return m.jxtcpl return m.jxtcpl
} }

View File

@ -26,13 +26,15 @@ type Repository struct {
lightMap map[string]*Light lightMap map[string]*Light
alarmMap map[string]*Alarm alarmMap map[string]*Alarm
stationMap map[string]*Station stationMap map[string]*Station
mkxMap map[string]*Mkx psdPslMap map[string]*PsdPsl
keyMap map[string]*Key keyMap map[string]*Key
linkMap map[string]*Link linkMap map[string]*Link
platformMap map[string]*Platform platformMap map[string]*Platform
centralizedMap map[string]*proto.CentralizedStationRef centralizedMap map[string]*proto.CentralizedStationRef
ckmMap map[string]*Ckm ckmMap map[string]*Ckm
ckmPslMap map[string]*CkmPsl
xcjMap map[string]*Xcj xcjMap map[string]*Xcj
PipeMap map[string]*Pipe //ISCS 管线 PipeMap map[string]*Pipe //ISCS 管线
PipeFittingMap map[string]*PipeFitting //ISCS 管件 PipeFittingMap map[string]*PipeFitting //ISCS 管件
CircuitBreakerMap map[string]*CircuitBreaker //ISCS 断路器 CircuitBreakerMap map[string]*CircuitBreaker //ISCS 断路器
@ -76,7 +78,7 @@ func newRepository(id string, version string) *Repository {
lightMap: make(map[string]*Light), lightMap: make(map[string]*Light),
alarmMap: make(map[string]*Alarm), alarmMap: make(map[string]*Alarm),
stationMap: make(map[string]*Station), stationMap: make(map[string]*Station),
mkxMap: make(map[string]*Mkx), psdPslMap: make(map[string]*PsdPsl),
keyMap: make(map[string]*Key), keyMap: make(map[string]*Key),
platformMap: make(map[string]*Platform), platformMap: make(map[string]*Platform),
centralizedMap: make(map[string]*proto.CentralizedStationRef), centralizedMap: make(map[string]*proto.CentralizedStationRef),
@ -293,9 +295,9 @@ func (repo *Repository) PsdList() []*Psd {
} }
return list return list
} }
func (repo *Repository) MkxList() []*Mkx { func (repo *Repository) MkxList() []*PsdPsl {
var list []*Mkx var list []*PsdPsl
for _, model := range repo.mkxMap { for _, model := range repo.psdPslMap {
list = append(list, model) list = append(list, model)
} }
return list return list
@ -340,6 +342,14 @@ func (repo *Repository) XcjList() []*Xcj {
return list return list
} }
func (repo *Repository) CkmPslList() []*CkmPsl {
var list []*CkmPsl
for _, model := range repo.ckmPslMap {
list = append(list, model)
}
return list
}
func (repo *Repository) GetCentralizedStationRef(centralizedStationId string) *proto.CentralizedStationRef { func (repo *Repository) GetCentralizedStationRef(centralizedStationId string) *proto.CentralizedStationRef {
return repo.centralizedMap[centralizedStationId] return repo.centralizedMap[centralizedStationId]
} }

View File

@ -123,8 +123,8 @@ func buildModels(source *proto.Repository, repository *Repository) error {
repository.alarmMap[m.Id()] = m repository.alarmMap[m.Id()] = m
} }
for _, protoData := range source.Mkxs { for _, protoData := range source.Mkxs {
m := NewMkx(protoData.Id) m := NewPsdPsl(protoData.Id)
repository.mkxMap[m.Id()] = m repository.psdPslMap[m.Id()] = m
} }
for _, protoData := range source.Keys { for _, protoData := range source.Keys {
m := NewKey(protoData.Id, protoData.Code, protoData.Gear) m := NewKey(protoData.Id, protoData.Code, protoData.Gear)
@ -142,6 +142,10 @@ func buildModels(source *proto.Repository, repository *Repository) error {
m := NewXcj(protoData.Id) m := NewXcj(protoData.Id)
repository.xcjMap[m.Id()] = m repository.xcjMap[m.Id()] = m
} }
for _, protoData := range source.CkmPsls {
m := NewCkmPsl(protoData.Id)
repository.ckmPslMap[m.Id()] = m
}
err := repository.generateCoordinateInfo(source.MainCoordinateSystem) err := repository.generateCoordinateInfo(source.MainCoordinateSystem)
if err != nil { if err != nil {
return err return err
@ -208,9 +212,22 @@ func buildModelRelationship(source *proto.Repository, repository *Repository) er
if err != nil { if err != nil {
return err return err
} }
err = buildCkmPslRelationShip(source, repository)
return err return err
} }
func buildCkmPslRelationShip(source *proto.Repository, repository *Repository) error {
for _, protoData := range source.CkmPsls {
psl := repository.ckmPslMap[protoData.Id]
psl.ckm = repository.ckmMap[protoData.CkmId]
psl.gma = repository.buttonMap[protoData.GmaId]
psl.kma = repository.buttonMap[protoData.KmaId]
psl.mpla = repository.buttonMap[protoData.MplaId]
psl.mmsa = repository.buttonMap[protoData.MmsaId]
}
return nil
}
func buildXcjRelationShip(source *proto.Repository, repo *Repository) error { func buildXcjRelationShip(source *proto.Repository, repo *Repository) error {
for _, protoData := range source.Ckms { for _, protoData := range source.Ckms {
ckm := repo.ckmMap[protoData.Id] ckm := repo.ckmMap[protoData.Id]
@ -270,7 +287,7 @@ func buildCentralizedStationRelationShip(source *proto.Repository, repo *Reposit
} }
func buildMkxRelationShip(source *proto.Repository, repo *Repository) error { func buildMkxRelationShip(source *proto.Repository, repo *Repository) error {
for _, protoData := range source.Mkxs { for _, protoData := range source.Mkxs {
mkx := repo.mkxMap[protoData.Id] mkx := repo.psdPslMap[protoData.Id]
mkx.psd = repo.psdMap[protoData.PsdId] mkx.psd = repo.psdMap[protoData.PsdId]
mkx.pcb = repo.buttonMap[protoData.PcbaId] mkx.pcb = repo.buttonMap[protoData.PcbaId]
mkx.pcbpl = repo.buttonMap[protoData.PcbplaId] mkx.pcbpl = repo.buttonMap[protoData.PcbplaId]

View File

@ -22,10 +22,20 @@ func NewCkmSys() *CkmSys {
func (p *CkmSys) Update(world ecs.World) { func (p *CkmSys) Update(world ecs.World) {
worldData := entity.GetWorldData(world) worldData := entity.GetWorldData(world)
p.query.Each(world, func(entry *ecs.Entry) { p.query.Each(world, func(entry *ecs.Entry) {
//车库门故障(状态丢失)
if entry.HasComponent(component.CkmMgzTag) {
return
}
posCom := component.FixedPositionTransformType.Get(entry) posCom := component.FixedPositionTransformType.Get(entry)
state := component.CkmStateType.Get(entry) state := component.CkmStateType.Get(entry)
if entry.HasComponent(component.CkmCircuitType) { remote := true //是否远程模式
circuit := component.CkmCircuitType.Get(entry) circuit := component.CkmCircuitType.Get(entry) //目前不考虑没有车库门电路的情况
//车库门PSL
if entry.HasComponent(component.CkmPslType) {
ckmPsl := component.CkmPslType.Get(entry)
component.RelayDriveType.Get(circuit.MPLJ).Td = component.BitStateType.Get(ckmPsl.MPLA).Val
remote = component.BitStateType.Get(ckmPsl.MMSA).Val
}
//门开/关继电器及状态 //门开/关继电器及状态
if posCom.Pos == consts.TwoPosMin { if posCom.Pos == consts.TwoPosMin {
component.RelayDriveType.Get(circuit.MGJ).Td = true component.RelayDriveType.Get(circuit.MGJ).Td = true
@ -40,6 +50,7 @@ func (p *CkmSys) Update(world ecs.World) {
component.RelayDriveType.Get(circuit.MGZJ).Td = entry.HasComponent(component.CkmMgzTag) component.RelayDriveType.Get(circuit.MGZJ).Td = entry.HasComponent(component.CkmMgzTag)
state.Mgz = entry.HasComponent(component.CkmMgzTag) state.Mgz = entry.HasComponent(component.CkmMgzTag)
//开/关门继电器驱动状态 //开/关门继电器驱动状态
if remote {
kmBit, err := worldData.QueryQdBit(component.UidType.Get(circuit.KMJ).Id) kmBit, err := worldData.QueryQdBit(component.UidType.Get(circuit.KMJ).Id)
if err == nil { if err == nil {
component.RelayDriveType.Get(circuit.KMJ).Td = kmBit component.RelayDriveType.Get(circuit.KMJ).Td = kmBit
@ -52,17 +63,15 @@ func (p *CkmSys) Update(world ecs.World) {
} else { } else {
slog.Error(err.Error()) slog.Error(err.Error())
} }
} else {
ckmPsl := component.CkmPslType.Get(entry)
component.RelayDriveType.Get(circuit.KMJ).Td = component.BitStateType.Get(ckmPsl.KMA).Val
component.RelayDriveType.Get(circuit.GMJ).Td = component.BitStateType.Get(ckmPsl.GMA).Val
}
//车库门状态
state.Km = component.BitStateType.Get(circuit.KMJ).Val state.Km = component.BitStateType.Get(circuit.KMJ).Val
state.Gm = component.BitStateType.Get(circuit.GMJ).Val state.Gm = component.BitStateType.Get(circuit.GMJ).Val
} else {
if posCom.Pos == consts.TwoPosMin {
state.Close = true
} else {
state.Close = false
}
state.Mgz = entry.HasComponent(component.CkmMgzTag) state.Mgz = entry.HasComponent(component.CkmMgzTag)
}
//驱动 //驱动
if state.Gm { if state.Gm {
posCom.Speed = -component.CalculateTwoPositionAvgSpeed(3*1000, world.Tick()) posCom.Speed = -component.CalculateTwoPositionAvgSpeed(3*1000, world.Tick())