[修改]11号线联锁通信暂时提交

This commit is contained in:
thesai 2024-08-28 11:32:27 +08:00
parent 99ebcb04e5
commit a94fdb12f7
3 changed files with 22 additions and 235 deletions

View File

@ -59,43 +59,3 @@ func SwitchKeyGear(w ecs.World, id string, gear int32) error {
})
return result.Err
}
//func SetBypassBtn(w ecs.World, id string, p request_proto.BypassOperationReq_Operation) error {
//
// result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
// wd := entity.GetWorldData(w)
// entry, ok := wd.EntityMap[id]
// if ok {
// state := component.BitStateType.Get(entry)
// state.Bypass.BypassEnable = convertBypassBoolVal(p)
// state.Bypass.OldVal = state.Val
// } else {
// return ecs.NewErrResult(fmt.Errorf("未找到id=%s的按钮", id))
// }
// return ecs.NewOkEmptyResult()
// })
// return result.Err
//}
//func SetBypassSwitchKey(w ecs.World, id string, p request_proto.BypassOperationReq_Operation) error {
// result := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
// wd := entity.GetWorldData(w)
// entry, ok := wd.EntityMap[id]
// if ok {
// state := component.GearStateType.Get(entry)
// state.BypassEnable = convertBypassBoolVal(p)
// state.OldVal = state.Val == 0
// } else {
// return ecs.NewErrResult(fmt.Errorf("未找到id=%s的钥匙开关", id))
// }
// return ecs.NewOkEmptyResult()
// })
// return result.Err
//}
//
//func convertBypassBoolVal(p request_proto.BypassOperationReq_Operation) bool {
// val := true
// if p == request_proto.BypassOperationReq_bypass_reset {
// val = false
// }
// return val
//}

View File

@ -8,8 +8,8 @@ import (
"strings"
)
// AxleSectionFaultOccDrive 区段故障占用设置
func AxleSectionFaultOccDrive(w ecs.World, sectionId string, set bool) error {
// PhysicalSectionFaultOccDrive 区段故障占用设置
func PhysicalSectionFaultOccDrive(w ecs.World, sectionId string, set bool) error {
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
wd := entity.GetWorldData(w)
sectionModel := wd.Repo.FindPhysicalSection(sectionId)
@ -35,16 +35,16 @@ func AxleSectionFaultOccDrive(w ecs.World, sectionId string, set bool) error {
return r.Err
}
// AxleSectionDrstDrive 直接复位
func AxleSectionDrstDrive(w ecs.World, sectionId string) (*AxleSectionState, error) {
r := <-ecs.Request[*AxleSectionState](w, func() ecs.Result[*AxleSectionState] {
// PhysicalSectionDrstDrive 直接复位
func PhysicalSectionDrstDrive(w ecs.World, sectionId string) (*PhysicalSectionState, error) {
r := <-ecs.Request[*PhysicalSectionState](w, func() ecs.Result[*PhysicalSectionState] {
wd := entity.GetWorldData(w)
entry := wd.EntityMap[sectionId]
if entry == nil {
return ecs.NewResult[*AxleSectionState](nil, fmt.Errorf("区段[%s]实体不存在", sectionId))
return ecs.NewResult[*PhysicalSectionState](nil, fmt.Errorf("区段[%s]实体不存在", sectionId))
}
axleManager := component.PhysicalSectionManagerType.Get(entry)
state := &AxleSectionState{}
state := &PhysicalSectionState{}
if axleManager.Count != 0 {
state.Rjo = true
} else {
@ -56,16 +56,16 @@ func AxleSectionDrstDrive(w ecs.World, sectionId string) (*AxleSectionState, err
return r.Val, r.Err
}
// AxleSectionPdrstDrive 预复位
func AxleSectionPdrstDrive(w ecs.World, sectionId string) (*AxleSectionState, error) {
r := <-ecs.Request[*AxleSectionState](w, func() ecs.Result[*AxleSectionState] {
// PhysicalSectionPdrstDrive 预复位
func PhysicalSectionPdrstDrive(w ecs.World, sectionId string) (*PhysicalSectionState, error) {
r := <-ecs.Request[*PhysicalSectionState](w, func() ecs.Result[*PhysicalSectionState] {
wd := entity.GetWorldData(w)
entry := wd.EntityMap[sectionId]
if entry == nil {
return ecs.NewResult[*AxleSectionState](nil, fmt.Errorf("区段[%s]实体不存在", sectionId))
return ecs.NewResult[*PhysicalSectionState](nil, fmt.Errorf("区段[%s]实体不存在", sectionId))
}
axleManager := component.PhysicalSectionManagerType.Get(entry)
state := &AxleSectionState{}
state := &PhysicalSectionState{}
if axleManager.Count != 0 {
state.Rjo = true
} else {
@ -76,11 +76,11 @@ func AxleSectionPdrstDrive(w ecs.World, sectionId string) (*AxleSectionState, er
return r.Val, r.Err
}
// FindAxleSectionsStatus 获取计轴区段的相关状态
func FindAxleSectionsStatus(w ecs.World, sectionIds []string) ([]*AxleSectionState, error) {
r := <-ecs.Request[[]*AxleSectionState](w, func() ecs.Result[[]*AxleSectionState] {
// FindPhysicalSectionsStatus 获取物理区段的相关状态
func FindPhysicalSectionsStatus(w ecs.World, sectionIds []string) ([]*PhysicalSectionState, error) {
r := <-ecs.Request[[]*PhysicalSectionState](w, func() ecs.Result[[]*PhysicalSectionState] {
wd := entity.GetWorldData(w)
var msg []*AxleSectionState
var msg []*PhysicalSectionState
var esb = strings.Builder{} //收集未找到的区段的id
for _, sectionId := range sectionIds {
entry := wd.EntityMap[sectionId]
@ -89,14 +89,14 @@ func FindAxleSectionsStatus(w ecs.World, sectionIds []string) ([]*AxleSectionSta
continue
}
axleManager := component.PhysicalSectionManagerType.Get(entry)
msg = append(msg, &AxleSectionState{
msg = append(msg, &PhysicalSectionState{
Id: sectionId,
Clr: !axleManager.Occupied,
Occ: axleManager.Occupied,
})
}
if esb.Len() > 0 {
return ecs.NewResult(msg, fmt.Errorf("区段非计轴区段或计轴区段状态不存在:[%s]", esb.String()))
return ecs.NewResult(msg, fmt.Errorf("区段非物理区段或物理区段状态不存在:[%s]", esb.String()))
} else {
return ecs.NewResult(msg, nil)
}
@ -104,14 +104,14 @@ func FindAxleSectionsStatus(w ecs.World, sectionIds []string) ([]*AxleSectionSta
return r.Val, r.Err
}
type AxleSectionState struct {
type PhysicalSectionState struct {
//uid
Id string
//0-bit7 计轴出清
//0-bit7 区段出清
Clr bool
//0-bit6 计轴占用
//0-bit6 区段占用
Occ bool
//1-bit6 计轴复位反馈
//1-bit6 区段复位反馈
Rac bool
//1-bit5 运营原因拒绝计轴复位
Rjo bool

View File

@ -1,173 +0,0 @@
package fi
//
//import (
// "fmt"
// "strings"
//
// "joylink.club/ecs"
// "joylink.club/rtsssimulation/component"
// "joylink.club/rtsssimulation/entity"
//)
//
//// AxleSectionDrstDrive 计轴直接复位操作
////
//// set : true-设置false-取消
//func AxleSectionDrstDrive(w ecs.World, sectionId string, set bool) error {
// r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
// wd := entity.GetWorldData(w)
// //
// sectionModel := wd.Repo.FindPhysicalSection(sectionId)
// if sectionModel == nil {
// return ecs.NewErrResult(fmt.Errorf("区段模型[%s]不存实体", sectionId))
// }
// // if set {
// // axleSectionEntry := wd.EntityMap[sectionId]
// // if !axleSectionEntry.HasComponent(component.AxleSectionFaultTag) {
// // return ecs.NewErrResult(fmt.Errorf("区段[%s]非故障占用,无法进行复位操作", sectionId))
// // }
// // }
// //
// faDcAxleDeviceEntry := entity.FindAxleManageDevice(wd, sectionModel.CentralizedStation())
//
// if faDcAxleDeviceEntry == nil {
// return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]实体不存在", sectionModel.CentralizedStation()))
// }
// faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry)
// axleRuntime := faDcAxleDevice.FindAdr(sectionId)
// if axleRuntime == nil {
// return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]中不存在区段[%s]的计轴设备", sectionModel.CentralizedStation(), sectionId))
// }
// axleRuntime.Drst = set
// //
// return ecs.NewOkEmptyResult()
// })
// return r.Err
//}
//
//// AxleSectionPdrstDrive 计轴预复位操作
////
//// set : true-设置false-取消
//func AxleSectionPdrstDrive(w ecs.World, sectionId string, set bool) error {
// r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
// wd := entity.GetWorldData(w)
// sectionModel := wd.Repo.FindPhysicalSection(sectionId)
// if sectionModel == nil {
// return ecs.NewErrResult(fmt.Errorf("区段模型[%s]不存实体", sectionId))
// }
// // if set {
// // axleSectionEntry := wd.EntityMap[sectionId]
// // if !axleSectionEntry.HasComponent(component.AxleSectionFaultTag) {
// // return ecs.NewErrResult(fmt.Errorf("区段[%s]非故障占用,无法进行复位操作", sectionId))
// // }
// // }
// //
// faDcAxleDeviceEntry := entity.FindAxleManageDevice(wd, sectionModel.CentralizedStation())
//
// if faDcAxleDeviceEntry == nil {
// return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]实体不存在", sectionModel.CentralizedStation()))
// }
// faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry)
// axleRuntime, ok := faDcAxleDevice.Adrs[sectionId]
// if !ok {
// return ecs.NewErrResult(fmt.Errorf("计轴管理设备[%s]中不存在区段[%s]的计轴设备", sectionModel.CentralizedStation(), sectionId))
// }
// axleRuntime.Pdrst = set
// //
// return ecs.NewOkEmptyResult()
// })
// return r.Err
//}
//
//// AxleSectionFaultOccDrive 区段故障占用设置
////
//// set : true - 设置故障占用false - 取消故障占用
//func AxleSectionFaultOccDrive(w ecs.World, sectionId string, set bool) error {
// r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
// wd := entity.GetWorldData(w)
// sectionModel := wd.Repo.FindPhysicalSection(sectionId)
// if sectionModel == nil {
// return ecs.NewErrResult(fmt.Errorf("区段模型[%s]不存实体", sectionId))
// }
// //
// sectionEntry := wd.EntityMap[sectionId]
// if sectionEntry == nil {
// return ecs.NewErrResult(fmt.Errorf("区段[%s]实体不存在", sectionId))
// }
// if set { //计轴故障设置
// if !sectionEntry.HasComponent(component.AxleSectionFaultTag) {
// sectionEntry.AddComponent(component.AxleSectionFaultTag)
// }
// } else { //计轴故障取消
// if sectionEntry.HasComponent(component.AxleSectionFaultTag) {
// sectionEntry.RemoveComponent(component.AxleSectionFaultTag)
// }
// }
// //
// return ecs.NewOkEmptyResult()
// })
// return r.Err
//}
//
//// FindAxleSectionsStatus 获取计轴区段的相关状态
//func FindAxleSectionsStatus(w ecs.World, sectionIds []string) ([]*AxleSectionState, error) {
// r := <-ecs.Request[[]*AxleSectionState](w, func() ecs.Result[[]*AxleSectionState] {
// wd := entity.GetWorldData(w)
// var msg []*AxleSectionState
// var esb = strings.Builder{} //收集未找到的区段的id
// for _, sectionId := range sectionIds {
// find := false
// sectionModel := wd.Repo.FindPhysicalSection(sectionId)
// if sectionModel != nil {
// faDcAxleDeviceEntry := entity.FindAxleManageDevice(wd, sectionModel.CentralizedStation())
// if faDcAxleDeviceEntry != nil {
// faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry)
// axleDevice := faDcAxleDevice.FindAdr(sectionId)
// if axleDevice != nil {
// sectionEntry, _ := entity.GetEntityByUid(w, sectionId)
// if sectionEntry != nil {
// if sectionEntry.HasComponent(component.AxlePhysicalSectionType) { //计轴物理区段实体
// as := &AxleSectionState{}
// state := component.PhysicalSectionStateType.Get(sectionEntry)
// as.Id = component.UidType.Get(sectionEntry).Id
// as.Clr = !state.Occ
// as.Occ = state.Occ
// as.Rac = axleDevice.Rac
// as.Rjt = axleDevice.Rjt
// as.Rjo = axleDevice.Rjo
// //
// msg = append(msg, as)
// find = true
// }
// }
// }
// }
// }
// //
// if !find {
// esb.WriteString(fmt.Sprintf("%s,", sectionId))
// }
// } //for
// if esb.Len() > 0 {
// return ecs.NewResult(msg, fmt.Errorf("区段非计轴区段或计轴区段状态不存在:[%s]", esb.String()))
// } else {
// return ecs.NewResult(msg, nil)
// }
// })
// return r.Val, r.Err
//}
//
//type AxleSectionState struct {
// //uid
// Id string
// //0-bit7 计轴出清
// Clr bool
// //0-bit6 计轴占用
// Occ bool
// //1-bit6 计轴复位反馈
// Rac bool
// //1-bit5 运营原因拒绝计轴复位
// Rjo bool
// //1-bit4 技术原因拒绝计轴复位
// Rjt bool
//}