计轴rssp 集成
This commit is contained in:
parent
13af2d6ff9
commit
51203ce53c
101
fi/section.go
101
fi/section.go
@ -5,6 +5,7 @@ import (
|
||||
"joylink.club/ecs"
|
||||
"joylink.club/rtsssimulation/component"
|
||||
"joylink.club/rtsssimulation/entity"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// AxleSectionDrstDrive 计轴直接复位操作
|
||||
@ -122,3 +123,103 @@ func AxleSectionTrainDrive(w ecs.World, sectionId string, trainIn bool) error {
|
||||
})
|
||||
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.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 {
|
||||
//0-bit7 计轴出清
|
||||
Clr bool
|
||||
//0-bit6 计轴占用
|
||||
Occ bool
|
||||
//1-bit6 计轴复位反馈
|
||||
Rac bool
|
||||
//1-bit5 运营原因拒绝计轴复位
|
||||
Rjo bool
|
||||
//1-bit4 技术原因拒绝计轴复位
|
||||
Rjt bool
|
||||
}
|
||||
|
||||
// AxleSectionRstDrive 复位(直接复位、预复位)
|
||||
func AxleSectionRstDrive(w ecs.World, cmds []*AxleSectionCmd) error {
|
||||
r := <-ecs.Request[ecs.EmptyType](w, func() ecs.Result[ecs.EmptyType] {
|
||||
wd := entity.GetWorldData(w)
|
||||
var esb = strings.Builder{} //收集未找到的区段的id
|
||||
find := false
|
||||
for _, cmd := range cmds {
|
||||
sectionId := cmd.SectionId
|
||||
sectionModel := wd.Repo.FindPhysicalSection(sectionId)
|
||||
if sectionModel != nil {
|
||||
faDcAxleDeviceEntry := entity.FindAxleManageDevice(wd, sectionModel.CentralizedStation())
|
||||
if faDcAxleDeviceEntry != nil {
|
||||
faDcAxleDevice := component.AxleManageDeviceType.Get(faDcAxleDeviceEntry)
|
||||
axleRuntime := faDcAxleDevice.FindAdr(sectionId)
|
||||
if axleRuntime != nil {
|
||||
axleRuntime.Pdrst = cmd.Pdrst
|
||||
axleRuntime.Drst = cmd.Drst
|
||||
find = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if !find {
|
||||
esb.WriteString(fmt.Sprintf("%s,", sectionId))
|
||||
}
|
||||
} //for
|
||||
if esb.Len() > 0 {
|
||||
return ecs.NewErrResult(fmt.Errorf("计轴区段复位操作,失败列表[%s]", esb.String()))
|
||||
} else {
|
||||
return ecs.NewOkEmptyResult()
|
||||
}
|
||||
})
|
||||
return r.Err
|
||||
}
|
||||
|
||||
type AxleSectionCmd struct {
|
||||
SectionId string
|
||||
Drst bool
|
||||
Pdrst bool
|
||||
}
|
||||
|
@ -300,6 +300,8 @@ message CentralizedStationRef {
|
||||
repeated CjData cjList = 3; // 采集继电器配置信息
|
||||
|
||||
repeated QdData qdList = 4; // 驱动继电器配置信息
|
||||
|
||||
repeated CiSectionCodePoint sectionCodePoints = 5;//物理区段码表
|
||||
}
|
||||
|
||||
message CjData {
|
||||
@ -325,3 +327,9 @@ message AsdGroup {
|
||||
int32 start = 2; //起始子门索引
|
||||
int32 end = 3; //终止子门索引
|
||||
}
|
||||
|
||||
//联锁物理区段码位
|
||||
message CiSectionCodePoint{
|
||||
int32 row = 1;//所在行
|
||||
string sectionId = 2;//物理区段id
|
||||
}
|
Loading…
Reference in New Issue
Block a user