From a94fdb12f720a5d9bbf57b1916e8ba5990130e6e Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Wed, 28 Aug 2024 11:32:27 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E6=94=B9]11=E5=8F=B7=E7=BA=BF?= =?UTF-8?q?=E8=81=94=E9=94=81=E9=80=9A=E4=BF=A1=E6=9A=82=E6=97=B6=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fi/{ibp.go => button.go} | 40 ----- fi/{axle_section.go => physical_section.go} | 44 ++--- fi/section.go | 173 -------------------- 3 files changed, 22 insertions(+), 235 deletions(-) rename fi/{ibp.go => button.go} (53%) rename fi/{axle_section.go => physical_section.go} (61%) delete mode 100644 fi/section.go diff --git a/fi/ibp.go b/fi/button.go similarity index 53% rename from fi/ibp.go rename to fi/button.go index 84aede8..77e043b 100644 --- a/fi/ibp.go +++ b/fi/button.go @@ -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 -//} diff --git a/fi/axle_section.go b/fi/physical_section.go similarity index 61% rename from fi/axle_section.go rename to fi/physical_section.go index 22b8562..a0c4984 100644 --- a/fi/axle_section.go +++ b/fi/physical_section.go @@ -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 diff --git a/fi/section.go b/fi/section.go deleted file mode 100644 index 1f9fe53..0000000 --- a/fi/section.go +++ /dev/null @@ -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 -//}