增加间隙探测继电器及相关逻辑;修改屏蔽门控制逻辑实现
This commit is contained in:
parent
3c08644dde
commit
d05706b3e5
@ -19,20 +19,18 @@ type PsdCircuit struct {
|
||||
//屏蔽门表示继电器
|
||||
MGJ *ecs.Entry
|
||||
MPLJ *ecs.Entry
|
||||
//启动探测继电器
|
||||
QDTCJ *ecs.Entry
|
||||
//停止探测继电器
|
||||
TZTCJ *ecs.Entry
|
||||
//大概就是表示探测过程中出现异常
|
||||
ZAWJ *ecs.Entry
|
||||
//间隙探测旁路继电器
|
||||
JXTCPLJ *ecs.Entry
|
||||
//一些不知道如何使用的继电器,为了使得采集、驱动逻辑正常,先构建出来
|
||||
UnusedJ []*ecs.Entry
|
||||
}
|
||||
|
||||
var PsdInterlockDriveCircuitType = ecs.NewComponentType[PsdInterlockDriveCircuit]()
|
||||
|
||||
// PsdInterlockDriveCircuit 屏蔽门联锁驱动电路
|
||||
type PsdInterlockDriveCircuit struct {
|
||||
//屏蔽门驱动继电器接通状态
|
||||
GMJ bool
|
||||
KMJ4 bool
|
||||
KMJ8 bool
|
||||
}
|
||||
|
||||
var AsdCannotOpenTag = ecs.NewTag()
|
||||
var AsdCannotCloseTag = ecs.NewTag()
|
||||
|
||||
@ -96,4 +94,9 @@ type Psc struct {
|
||||
MkxKM bool
|
||||
MkxGM bool
|
||||
MkxPL bool
|
||||
|
||||
QDTC bool
|
||||
TZTC bool
|
||||
ZAW bool
|
||||
JXTCPL bool
|
||||
}
|
||||
|
@ -59,6 +59,14 @@ func loadPsdCircuit(world ecs.World, entry *ecs.Entry, psd *repository.Psd, entr
|
||||
circuit.MGJ = NewRelayEntity(world, relay, entryMap)
|
||||
case "XMPLJ", "SMPLJ":
|
||||
circuit.MPLJ = NewRelayEntity(world, relay, entryMap)
|
||||
case "SQDTCJ", "XQDTCJ":
|
||||
circuit.QDTCJ = NewRelayEntity(world, relay, entryMap)
|
||||
case "STZTCJ", "XTZTCJ":
|
||||
circuit.TZTCJ = NewRelayEntity(world, relay, entryMap)
|
||||
case "SZAWJ", "XZAWJ":
|
||||
circuit.ZAWJ = NewRelayEntity(world, relay, entryMap)
|
||||
case "SJXTCPLJ", "XJXTCPLJ":
|
||||
circuit.JXTCPLJ = NewRelayEntity(world, relay, entryMap)
|
||||
default:
|
||||
circuit.UnusedJ = append(circuit.UnusedJ, NewRelayEntity(world, relay, entryMap))
|
||||
}
|
||||
@ -66,7 +74,6 @@ func loadPsdCircuit(world ecs.World, entry *ecs.Entry, psd *repository.Psd, entr
|
||||
}
|
||||
entry.AddComponent(component.PsdCircuitType)
|
||||
component.PsdCircuitType.Set(entry, circuit)
|
||||
entry.AddComponent(component.PsdInterlockDriveCircuitType)
|
||||
}
|
||||
|
||||
func NewPsdEntry(world ecs.World, psd *repository.Psd, worldData *component.WorldData) *ecs.Entry {
|
||||
|
232
fi/psd.go
232
fi/psd.go
@ -13,7 +13,10 @@ func SetInterlockKm4(world ecs.World, id string) error {
|
||||
wd := entity.GetWorldData(world)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
setPsdKm(entry, 4)
|
||||
err := setInterlockKm(wd, entry, 4)
|
||||
if err != nil {
|
||||
return ecs.NewErrResult(err)
|
||||
}
|
||||
} else {
|
||||
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
|
||||
}
|
||||
@ -27,7 +30,10 @@ func CancelInterlockKm4(world ecs.World, id string) error {
|
||||
wd := entity.GetWorldData(world)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
cancelPsdKm(entry, 4)
|
||||
err := cancelInterlockKm(wd, entry, 4)
|
||||
if err != nil {
|
||||
return ecs.NewErrResult(err)
|
||||
}
|
||||
} else {
|
||||
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
|
||||
}
|
||||
@ -41,7 +47,10 @@ func SetInterlockKm8(world ecs.World, id string) error {
|
||||
wd := entity.GetWorldData(world)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
setPsdKm(entry, 8)
|
||||
err := setInterlockKm(wd, entry, 8)
|
||||
if err != nil {
|
||||
return ecs.NewErrResult(err)
|
||||
}
|
||||
} else {
|
||||
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
|
||||
}
|
||||
@ -55,7 +64,10 @@ func CancelInterlockKm8(world ecs.World, id string) error {
|
||||
wd := entity.GetWorldData(world)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
cancelPsdKm(entry, 8)
|
||||
err := cancelInterlockKm(wd, entry, 8)
|
||||
if err != nil {
|
||||
return ecs.NewErrResult(err)
|
||||
}
|
||||
} else {
|
||||
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
|
||||
}
|
||||
@ -69,7 +81,10 @@ func SetInterlockGm(world ecs.World, id string) error {
|
||||
wd := entity.GetWorldData(world)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
setPsdGm(entry)
|
||||
err := setInterlockGm(wd, entry)
|
||||
if err != nil {
|
||||
return ecs.NewErrResult(err)
|
||||
}
|
||||
} else {
|
||||
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
|
||||
}
|
||||
@ -83,7 +98,10 @@ func CancelInterlockGm(world ecs.World, id string) error {
|
||||
wd := entity.GetWorldData(world)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
cancelPsdGm(entry)
|
||||
err := cancelInterlockGm(wd, entry)
|
||||
if err != nil {
|
||||
return ecs.NewErrResult(err)
|
||||
}
|
||||
} else {
|
||||
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
|
||||
}
|
||||
@ -134,14 +152,135 @@ func CancelPsdFault(world ecs.World, id string, fault component_proto.Psd_Fault,
|
||||
return result.Err
|
||||
}
|
||||
|
||||
func setPsdKm(psdEntry *ecs.Entry, group int) {
|
||||
if psdEntry.HasComponent(component.PsdInterlockDriveCircuitType) { //有联锁区段电路
|
||||
driveCircuit := component.PsdInterlockDriveCircuitType.Get(psdEntry)
|
||||
func SetQDTC(world ecs.World, id string) error {
|
||||
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(world)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
err := setQDTC(wd, entry)
|
||||
if err != nil {
|
||||
return ecs.NewErrResult(err)
|
||||
}
|
||||
} else {
|
||||
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
|
||||
}
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return result.Err
|
||||
}
|
||||
|
||||
func CancelQDTC(world ecs.World, id string) error {
|
||||
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(world)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
err := cancelQDTC(wd, entry)
|
||||
if err != nil {
|
||||
return ecs.NewErrResult(err)
|
||||
}
|
||||
} else {
|
||||
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
|
||||
}
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return result.Err
|
||||
}
|
||||
|
||||
func SetTZTC(world ecs.World, id string) error {
|
||||
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(world)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
err := setTZTC(wd, entry)
|
||||
if err != nil {
|
||||
return ecs.NewErrResult(err)
|
||||
}
|
||||
} else {
|
||||
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
|
||||
}
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return result.Err
|
||||
}
|
||||
|
||||
func CancelTZTC(world ecs.World, id string) error {
|
||||
result := <-ecs.Request[ecs.EmptyType](world, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(world)
|
||||
entry, ok := wd.EntityMap[id]
|
||||
if ok {
|
||||
err := cancelTZTC(wd, entry)
|
||||
if err != nil {
|
||||
return ecs.NewErrResult(err)
|
||||
}
|
||||
} else {
|
||||
return ecs.NewErrResult(fmt.Errorf("未找到id=%s的屏蔽门", id))
|
||||
}
|
||||
return ecs.NewOkEmptyResult()
|
||||
})
|
||||
return result.Err
|
||||
}
|
||||
|
||||
func cancelTZTC(wd *component.WorldData, psdEntry *ecs.Entry) error {
|
||||
if psdEntry.HasComponent(component.PsdCircuitType) {
|
||||
circuit := component.PsdCircuitType.Get(psdEntry)
|
||||
return wd.SetQdBit(component.UidType.Get(circuit.TZTCJ).Id, false)
|
||||
} else {
|
||||
psc := component.PscType.Get(psdEntry)
|
||||
psc.TZTC = false
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setTZTC(wd *component.WorldData, psdEntry *ecs.Entry) error {
|
||||
if psdEntry.HasComponent(component.PsdCircuitType) {
|
||||
circuit := component.PsdCircuitType.Get(psdEntry)
|
||||
return wd.SetQdBits([]*component.QdBitParam{
|
||||
component.NewQdBitParam(component.UidType.Get(circuit.QDTCJ).Id, false),
|
||||
component.NewQdBitParam(component.UidType.Get(circuit.TZTCJ).Id, true),
|
||||
})
|
||||
} else {
|
||||
psc := component.PscType.Get(psdEntry)
|
||||
psc.QDTC = false
|
||||
psc.TZTC = true
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func cancelQDTC(wd *component.WorldData, psdEntry *ecs.Entry) error {
|
||||
if psdEntry.HasComponent(component.PsdCircuitType) {
|
||||
circuit := component.PsdCircuitType.Get(psdEntry)
|
||||
return wd.SetQdBit(component.UidType.Get(circuit.QDTCJ).Id, false)
|
||||
} else {
|
||||
psc := component.PscType.Get(psdEntry)
|
||||
psc.QDTC = false
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setQDTC(wd *component.WorldData, psdEntry *ecs.Entry) error {
|
||||
if psdEntry.HasComponent(component.PsdCircuitType) {
|
||||
circuit := component.PsdCircuitType.Get(psdEntry)
|
||||
return wd.SetQdBits([]*component.QdBitParam{
|
||||
component.NewQdBitParam(component.UidType.Get(circuit.QDTCJ).Id, true),
|
||||
component.NewQdBitParam(component.UidType.Get(circuit.TZTCJ).Id, false),
|
||||
})
|
||||
} else {
|
||||
psc := component.PscType.Get(psdEntry)
|
||||
psc.QDTC = true
|
||||
psc.TZTC = false
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 设置联锁开门
|
||||
func setInterlockKm(wd *component.WorldData, psdEntry *ecs.Entry, group int) error {
|
||||
if psdEntry.HasComponent(component.PsdCircuitType) { //有联锁区段电路
|
||||
circuit := component.PsdCircuitType.Get(psdEntry)
|
||||
switch group {
|
||||
case 4:
|
||||
setPsdDriveKm4(driveCircuit)
|
||||
return setInterlockDriveKm4(wd, circuit)
|
||||
case 8:
|
||||
setPsdDriveKm8(driveCircuit)
|
||||
return setInterlockDriveKm8(wd, circuit)
|
||||
}
|
||||
} else {
|
||||
psc := component.PscType.Get(psdEntry)
|
||||
@ -152,16 +291,18 @@ func setPsdKm(psdEntry *ecs.Entry, group int) {
|
||||
setPscKm8(psc)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func cancelPsdKm(psdEntry *ecs.Entry, group int) {
|
||||
if psdEntry.HasComponent(component.PsdInterlockDriveCircuitType) { //有联锁区段电路
|
||||
driveCircuit := component.PsdInterlockDriveCircuitType.Get(psdEntry)
|
||||
// 取消联锁开门
|
||||
func cancelInterlockKm(wd *component.WorldData, psdEntry *ecs.Entry, group int) error {
|
||||
if psdEntry.HasComponent(component.PsdCircuitType) { //有联锁区段电路
|
||||
circuit := component.PsdCircuitType.Get(psdEntry)
|
||||
switch group {
|
||||
case 4:
|
||||
driveCircuit.KMJ4 = false
|
||||
return wd.SetQdBit(component.UidType.Get(circuit.KMJ4).Id, false)
|
||||
case 8:
|
||||
driveCircuit.KMJ8 = false
|
||||
return wd.SetQdBit(component.UidType.Get(circuit.KMJ8).Id, false)
|
||||
}
|
||||
} else {
|
||||
psc := component.PscType.Get(psdEntry)
|
||||
@ -172,56 +313,75 @@ func cancelPsdKm(psdEntry *ecs.Entry, group int) {
|
||||
psc.InterlockKM8 = false
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setPsdGm(psdEntry *ecs.Entry) {
|
||||
if psdEntry.HasComponent(component.PsdInterlockDriveCircuitType) { //有联锁区段电路
|
||||
driveCircuit := component.PsdInterlockDriveCircuitType.Get(psdEntry)
|
||||
setPsdDriveGm(driveCircuit)
|
||||
// 设置联锁关门
|
||||
func setInterlockGm(wd *component.WorldData, psdEntry *ecs.Entry) error {
|
||||
if psdEntry.HasComponent(component.PsdCircuitType) { //有联锁区段电路
|
||||
circuit := component.PsdCircuitType.Get(psdEntry)
|
||||
return setInterlockDriveGm(wd, circuit)
|
||||
} else {
|
||||
psc := component.PscType.Get(psdEntry)
|
||||
setPscGm(psc)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func cancelPsdGm(psdEntry *ecs.Entry) {
|
||||
if psdEntry.HasComponent(component.PsdInterlockDriveCircuitType) { //有联锁区段电路
|
||||
driveCircuit := component.PsdInterlockDriveCircuitType.Get(psdEntry)
|
||||
driveCircuit.GMJ = false
|
||||
// 取消联锁关门
|
||||
func cancelInterlockGm(wd *component.WorldData, psdEntry *ecs.Entry) error {
|
||||
if psdEntry.HasComponent(component.PsdCircuitType) {
|
||||
circuit := component.PsdCircuitType.Get(psdEntry)
|
||||
return wd.SetQdBit(component.UidType.Get(circuit.GMJ).Id, false)
|
||||
} else {
|
||||
psc := component.PscType.Get(psdEntry)
|
||||
psc.InterlockGM = false
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setPsdDriveKm4(driveCircuit *component.PsdInterlockDriveCircuit) {
|
||||
driveCircuit.KMJ4 = true
|
||||
driveCircuit.KMJ8 = false
|
||||
driveCircuit.GMJ = false
|
||||
// 联锁驱动4编组开门
|
||||
func setInterlockDriveKm4(wd *component.WorldData, circuit *component.PsdCircuit) error {
|
||||
return wd.SetQdBits([]*component.QdBitParam{
|
||||
component.NewQdBitParam(component.UidType.Get(circuit.GMJ).Id, false),
|
||||
component.NewQdBitParam(component.UidType.Get(circuit.KMJ4).Id, true),
|
||||
component.NewQdBitParam(component.UidType.Get(circuit.KMJ8).Id, false),
|
||||
})
|
||||
}
|
||||
|
||||
func setPsdDriveKm8(driveCircuit *component.PsdInterlockDriveCircuit) {
|
||||
driveCircuit.KMJ4 = false
|
||||
driveCircuit.KMJ8 = true
|
||||
driveCircuit.GMJ = false
|
||||
// 联锁驱动8编组开门
|
||||
func setInterlockDriveKm8(wd *component.WorldData, circuit *component.PsdCircuit) error {
|
||||
return wd.SetQdBits([]*component.QdBitParam{
|
||||
component.NewQdBitParam(component.UidType.Get(circuit.GMJ).Id, false),
|
||||
component.NewQdBitParam(component.UidType.Get(circuit.KMJ4).Id, false),
|
||||
component.NewQdBitParam(component.UidType.Get(circuit.KMJ8).Id, true),
|
||||
})
|
||||
}
|
||||
|
||||
func setPsdDriveGm(driveCircuit *component.PsdInterlockDriveCircuit) {
|
||||
driveCircuit.KMJ4 = false
|
||||
driveCircuit.KMJ8 = false
|
||||
driveCircuit.GMJ = true
|
||||
// 联锁驱动关门
|
||||
func setInterlockDriveGm(wd *component.WorldData, circuit *component.PsdCircuit) error {
|
||||
return wd.SetQdBits([]*component.QdBitParam{
|
||||
component.NewQdBitParam(component.UidType.Get(circuit.GMJ).Id, true),
|
||||
component.NewQdBitParam(component.UidType.Get(circuit.KMJ4).Id, false),
|
||||
component.NewQdBitParam(component.UidType.Get(circuit.KMJ8).Id, false),
|
||||
})
|
||||
}
|
||||
|
||||
// 直接设置PSC的状态4编组开门。在无屏蔽门电路时使用
|
||||
func setPscKm4(psc *component.Psc) {
|
||||
psc.InterlockKM4 = true
|
||||
psc.InterlockKM8 = false
|
||||
psc.InterlockGM = false
|
||||
}
|
||||
|
||||
// 直接设置PSC的状态8编组开门。在无屏蔽门电路时使用
|
||||
func setPscKm8(psc *component.Psc) {
|
||||
psc.InterlockKM4 = false
|
||||
psc.InterlockKM8 = true
|
||||
psc.InterlockGM = false
|
||||
}
|
||||
|
||||
// 直接设置PSC的状态关门。在无屏蔽门电路时使用
|
||||
func setPscGm(psc *component.Psc) {
|
||||
psc.InterlockKM4 = false
|
||||
psc.InterlockKM8 = false
|
||||
|
@ -4,8 +4,6 @@ import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/ecs/filter"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/component/component_proto"
|
||||
"joylink.club/rtsssimulation/consts"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
"strings"
|
||||
)
|
||||
@ -21,34 +19,45 @@ func NewPsdSys() *PsdSys {
|
||||
}
|
||||
|
||||
func (p *PsdSys) Update(world ecs.World) {
|
||||
worldData := entity.GetWorldData(world)
|
||||
p.query.Each(world, func(entry *ecs.Entry) {
|
||||
psc := component.PscType.Get(entry)
|
||||
//更新屏蔽门电路及PSC相关状态
|
||||
asdList := component.AsdListType.Get(entry)
|
||||
psdState := component.PsdStateType.Get(entry)
|
||||
if entry.HasComponent(component.PsdCircuitType) { //有屏蔽门电路
|
||||
psdDrive := component.PsdInterlockDriveCircuitType.Get(entry)
|
||||
psdCircuit := component.PsdCircuitType.Get(entry)
|
||||
p.exciteByDrive(psdCircuit, psdDrive)
|
||||
if psdCircuit.GMJ != nil {
|
||||
p.exciteGMJ(psdCircuit, psdDrive)
|
||||
p.exciteGMJ(worldData, psdCircuit)
|
||||
psc.InterlockGM = component.BitStateType.Get(psdCircuit.GMJ).Val
|
||||
}
|
||||
if psdCircuit.KMJ4 != nil {
|
||||
p.exciteKMJ4(psdCircuit, psdDrive)
|
||||
p.exciteKMJ4(worldData, psdCircuit)
|
||||
psc.InterlockKM4 = component.BitStateType.Get(psdCircuit.KMJ4).Val
|
||||
}
|
||||
if psdCircuit.KMJ8 != nil {
|
||||
p.exciteKMJ8(psdCircuit, psdDrive)
|
||||
p.exciteKMJ8(worldData, psdCircuit)
|
||||
psc.InterlockKM8 = component.BitStateType.Get(psdCircuit.KMJ8).Val
|
||||
}
|
||||
if psdCircuit.MGJ != nil {
|
||||
p.exciteMGJ(psdCircuit, asdList)
|
||||
psdState.Close = component.BitStateType.Get(psdCircuit.MGJ).Val
|
||||
}
|
||||
p.exciteMPLJ(world, psdCircuit, component.UidType.Get(entry))
|
||||
psc.InterlockMPL = component.BitStateType.Get(psdCircuit.MPLJ).Val
|
||||
if psdCircuit.MPLJ != nil {
|
||||
p.exciteMPLJ(world, psdCircuit, component.UidType.Get(entry))
|
||||
psc.InterlockMPL = component.BitStateType.Get(psdCircuit.MPLJ).Val
|
||||
}
|
||||
if psdCircuit.QDTCJ != nil {
|
||||
p.exciteQDTCJ(worldData, psdCircuit)
|
||||
psc.QDTC = component.BitStateType.Get(psdCircuit.QDTCJ).Val
|
||||
}
|
||||
if psdCircuit.TZTCJ != nil {
|
||||
p.exciteTZTCJ(worldData, psdCircuit)
|
||||
psc.TZTC = component.BitStateType.Get(psdCircuit.TZTCJ).Val
|
||||
}
|
||||
} else {
|
||||
psdState.Close = p.isAllAsdMotorClosed(asdList)
|
||||
}
|
||||
psdState := component.PsdStateType.Get(entry)
|
||||
p.updatePsdState(psdState, asdList)
|
||||
//更新站台门控箱电路及PSC相关状态
|
||||
pmc := component.PlatformMkxCircuitType.Get(entry)
|
||||
var pcbTd bool
|
||||
@ -114,92 +123,67 @@ func (p *PsdSys) gm(asdList *component.AsdList) {
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PsdSys) exciteByDrive(psd *component.PsdCircuit, drive *component.PsdInterlockDriveCircuit) {
|
||||
if drive.GMJ {
|
||||
component.RelayDriveType.Get(psd.GMJ).Td = true
|
||||
component.BitStateType.Get(psd.GMJ).Val = true
|
||||
}
|
||||
if drive.KMJ4 {
|
||||
component.RelayDriveType.Get(psd.KMJ4).Td = true
|
||||
component.BitStateType.Get(psd.KMJ4).Val = true
|
||||
}
|
||||
if drive.KMJ8 {
|
||||
component.RelayDriveType.Get(psd.KMJ8).Td = true
|
||||
component.BitStateType.Get(psd.KMJ8).Val = true
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PsdSys) exciteGMJ(psd *component.PsdCircuit, psdDrive *component.PsdInterlockDriveCircuit) {
|
||||
gmj := component.BitStateType.Get(psd.GMJ)
|
||||
kmj4 := component.BitStateType.Get(psd.KMJ4)
|
||||
kmj8 := component.BitStateType.Get(psd.KMJ8)
|
||||
if psdDrive.GMJ { //驱动电路接通
|
||||
component.RelayDriveType.Get(psd.GMJ).Td = true
|
||||
gmj.Val = true
|
||||
} else if gmj.Val {
|
||||
func (p *PsdSys) exciteGMJ(data *component.WorldData, circuit *component.PsdCircuit) {
|
||||
gmj := component.BitStateType.Get(circuit.GMJ)
|
||||
kmj4 := component.BitStateType.Get(circuit.KMJ4)
|
||||
kmj8 := component.BitStateType.Get(circuit.KMJ8)
|
||||
bit := data.GetQdBit(component.UidType.Get(circuit.GMJ).Id)
|
||||
if bit { //驱动
|
||||
component.RelayDriveType.Get(circuit.GMJ).Td = true
|
||||
} else if gmj.Val { //自保持
|
||||
if !kmj4.Val && !kmj8.Val {
|
||||
component.RelayDriveType.Get(psd.GMJ).Td = true
|
||||
component.RelayDriveType.Get(circuit.GMJ).Td = true
|
||||
} else {
|
||||
component.RelayDriveType.Get(psd.GMJ).Td = false
|
||||
gmj.Val = false
|
||||
component.RelayDriveType.Get(circuit.GMJ).Td = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PsdSys) exciteKMJ4(psd *component.PsdCircuit, psdDrive *component.PsdInterlockDriveCircuit) {
|
||||
kmj4 := component.BitStateType.Get(psd.KMJ4)
|
||||
gmj := component.BitStateType.Get(psd.GMJ)
|
||||
kmj8 := component.BitStateType.Get(psd.KMJ8)
|
||||
if psdDrive.KMJ4 {
|
||||
component.RelayDriveType.Get(psd.KMJ4).Td = true
|
||||
kmj4.Val = true
|
||||
} else if kmj4.Val {
|
||||
func (p *PsdSys) exciteKMJ4(data *component.WorldData, circuit *component.PsdCircuit) {
|
||||
kmj4 := component.BitStateType.Get(circuit.KMJ4)
|
||||
gmj := component.BitStateType.Get(circuit.GMJ)
|
||||
kmj8 := component.BitStateType.Get(circuit.KMJ8)
|
||||
bit := data.GetQdBit(component.UidType.Get(circuit.KMJ4).Id)
|
||||
if bit { //驱动
|
||||
component.RelayDriveType.Get(circuit.KMJ4).Td = true
|
||||
} else if kmj4.Val { //自保持
|
||||
if !gmj.Val && !kmj8.Val {
|
||||
component.RelayDriveType.Get(psd.KMJ4).Td = true
|
||||
component.RelayDriveType.Get(circuit.KMJ4).Td = true
|
||||
} else {
|
||||
component.RelayDriveType.Get(psd.KMJ4).Td = false
|
||||
kmj4.Val = false
|
||||
component.RelayDriveType.Get(circuit.KMJ4).Td = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PsdSys) exciteKMJ8(psd *component.PsdCircuit, psdDrive *component.PsdInterlockDriveCircuit) {
|
||||
kmj8 := component.BitStateType.Get(psd.KMJ8)
|
||||
gmj := component.BitStateType.Get(psd.GMJ)
|
||||
kmj4 := component.BitStateType.Get(psd.KMJ4)
|
||||
if psdDrive.KMJ4 {
|
||||
component.RelayDriveType.Get(psd.KMJ8).Td = true
|
||||
kmj8.Val = true
|
||||
} else if kmj8.Val {
|
||||
func (p *PsdSys) exciteKMJ8(data *component.WorldData, circuit *component.PsdCircuit) {
|
||||
kmj8 := component.BitStateType.Get(circuit.KMJ8)
|
||||
gmj := component.BitStateType.Get(circuit.GMJ)
|
||||
kmj4 := component.BitStateType.Get(circuit.KMJ4)
|
||||
bit := data.GetQdBit(component.UidType.Get(circuit.KMJ8).Id)
|
||||
if bit { //驱动
|
||||
component.RelayDriveType.Get(circuit.KMJ8).Td = true
|
||||
} else if kmj8.Val { //自保持
|
||||
if !gmj.Val && !kmj4.Val {
|
||||
component.RelayDriveType.Get(psd.KMJ8).Td = true
|
||||
component.RelayDriveType.Get(circuit.KMJ8).Td = true
|
||||
} else {
|
||||
component.RelayDriveType.Get(psd.KMJ8).Td = false
|
||||
kmj8.Val = false
|
||||
component.RelayDriveType.Get(circuit.KMJ8).Td = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PsdSys) exciteMGJ(psdCircuit *component.PsdCircuit, asdList *component.AsdList) {
|
||||
for _, asdEntry := range asdList.List {
|
||||
asdMotor := component.AsdMotorStateType.Get(asdEntry)
|
||||
if asdMotor.KM {
|
||||
component.BitStateType.Get(psdCircuit.MGJ).Val = false
|
||||
return
|
||||
}
|
||||
}
|
||||
component.BitStateType.Get(psdCircuit.MGJ).Val = true
|
||||
component.BitStateType.Get(psdCircuit.MGJ).Val = p.isAllAsdMotorClosed(asdList)
|
||||
}
|
||||
|
||||
func (p *PsdSys) updatePsdState(psdState *component_proto.PsdState, asdList *component.AsdList) {
|
||||
// 是否所有滑动门电机都是关闭状态(继电器表示)
|
||||
func (p *PsdSys) isAllAsdMotorClosed(asdList *component.AsdList) bool {
|
||||
for _, asdEntry := range asdList.List {
|
||||
position := component.TwoPositionTransformType.Get(asdEntry)
|
||||
if position.GetPos() != consts.TwoPosMin {
|
||||
psdState.Close = false
|
||||
return
|
||||
asdMotor := component.AsdMotorStateType.Get(asdEntry)
|
||||
if !asdMotor.MG {
|
||||
return false
|
||||
}
|
||||
}
|
||||
psdState.Close = true
|
||||
return true
|
||||
}
|
||||
|
||||
func (p *PsdSys) exciteMPLJ(world ecs.World, circuit *component.PsdCircuit, uid *component.Uid) {
|
||||
@ -227,3 +211,25 @@ func (p *PsdSys) exciteMPLJ(world ecs.World, circuit *component.PsdCircuit, uid
|
||||
component.RelayDriveType.Get(circuit.MPLJ).Td = component.BitStateType.Get(btnEntry).Val
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PsdSys) exciteQDTCJ(data *component.WorldData, circuit *component.PsdCircuit) {
|
||||
qdtcj := component.BitStateType.Get(circuit.QDTCJ)
|
||||
tztcj := component.BitStateType.Get(circuit.TZTCJ)
|
||||
bit := data.GetQdBit(component.UidType.Get(circuit.QDTCJ).Id)
|
||||
if bit { //驱动
|
||||
component.RelayDriveType.Get(circuit.QDTCJ).Td = true
|
||||
} else if qdtcj.Val { //自保持
|
||||
component.RelayDriveType.Get(circuit.QDTCJ).Td = !tztcj.Val
|
||||
}
|
||||
}
|
||||
|
||||
func (p *PsdSys) exciteTZTCJ(data *component.WorldData, circuit *component.PsdCircuit) {
|
||||
tztcj := component.BitStateType.Get(circuit.TZTCJ)
|
||||
qdtcj := component.BitStateType.Get(circuit.QDTCJ)
|
||||
bit := data.GetQdBit(component.UidType.Get(circuit.TZTCJ).Id)
|
||||
if bit { //驱动
|
||||
component.RelayDriveType.Get(circuit.TZTCJ).Td = true
|
||||
} else if tztcj.Val { //自保持
|
||||
component.RelayDriveType.Get(circuit.TZTCJ).Td = !qdtcj.Val
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user