【修改联锁采集逻辑】
This commit is contained in:
parent
c7f1137e59
commit
8b971c621b
|
@ -15,8 +15,8 @@ import (
|
|||
|
||||
// 联锁代理通信接口
|
||||
type InterlockMessageManager interface {
|
||||
CollectRelayInfo() []*message.InterlockSendMsgPkg
|
||||
HandleDriverInfo(b []byte)
|
||||
CollectInterlockRelayInfo() []*message.InterlockSendMsgPkg
|
||||
HandleInterlockDriverInfo(b []byte)
|
||||
GetInterlockRunConfig() *config.InterlockConfig
|
||||
}
|
||||
|
||||
|
|
|
@ -327,7 +327,7 @@ func (s *VerifySimulation) GetSemiPhysicalRunConfig() *config.VobcConfig {
|
|||
}
|
||||
|
||||
// 处理接到的联锁消息
|
||||
func (s *VerifySimulation) HandleDriverInfo(b []byte) {
|
||||
func (s *VerifySimulation) HandleInterlockDriverInfo(b []byte) {
|
||||
driverMsg := message.NewInterlockReceiveMsgPkg(0, 128, 8*131)
|
||||
driverMsg.Decode(b)
|
||||
driveState := driverMsg.DriveInfo
|
||||
|
@ -344,19 +344,46 @@ func (s *VerifySimulation) GetInterlockRunConfig() *config.InterlockConfig {
|
|||
}
|
||||
|
||||
// 采集联锁中的继电器消息
|
||||
func (s *VerifySimulation) CollectRelayInfo() []*message.InterlockSendMsgPkg {
|
||||
|
||||
msg := &message.InterlockSendMsgPkg{}
|
||||
relayArr := make([]string, 256)
|
||||
for index, id := range relayArr {
|
||||
if index%2 == 0 {
|
||||
msg.Info = append(msg.Info, fi.CollectXQCircuitState(s.World, id))
|
||||
} else {
|
||||
msg.Info = append(msg.Info, fi.CollectLXCircuitState(s.World, id))
|
||||
|
||||
func (s *VerifySimulation) CollectInterlockRelayInfo() []*message.InterlockSendMsgPkg {
|
||||
var msgPkgs []*message.InterlockSendMsgPkg
|
||||
for _, mapId := range s.MapIds { // 获取继电器地图信息
|
||||
var mapData *graphicData.RelayCabinetGraphicStorage
|
||||
switch QueryOnlyGiType(mapId) {
|
||||
case graphicData.PictureType_RelayCabinetLayout: // 继电器柜
|
||||
mapData = QueryGiData[*graphicData.RelayCabinetGraphicStorage](mapId)
|
||||
default:
|
||||
continue
|
||||
}
|
||||
// 配置继电器为空
|
||||
dataLenght := len(mapData.CiCjList.CjList) * int(mapData.CiCjList.DsCount)
|
||||
if dataLenght == 0 {
|
||||
continue
|
||||
}
|
||||
index := 0
|
||||
collectInfo := make([]bool, dataLenght)
|
||||
uidMap := QueryUidStructure[*RelayUidStructure](mapId)
|
||||
// 遍历继电器获取继电器状态
|
||||
for _, col := range mapData.CiCjList.CjList {
|
||||
for _, row := range col.BitList {
|
||||
rs := len(row.RefRelays) > 0
|
||||
for _, j := range row.RefRelays {
|
||||
u := uidMap.RelayIds[j.RelayId]
|
||||
if u == nil {
|
||||
panic(sys_error.New(fmt.Sprintf("地图【id:%d】不存在继电器的【comId:%s】UID映射关系", mapId, j.RelayId)))
|
||||
}
|
||||
if j.Position == graphicData.CjDataItem_Q {
|
||||
rs = rs && fi.CollectXQCircuitState(s.World, u.Uid)
|
||||
} else {
|
||||
rs = rs && fi.CollectLXCircuitState(s.World, u.Uid)
|
||||
}
|
||||
}
|
||||
collectInfo[index] = rs
|
||||
index++
|
||||
}
|
||||
}
|
||||
msgPkgs = append(msgPkgs, &message.InterlockSendMsgPkg{Info: collectInfo})
|
||||
}
|
||||
return []*message.InterlockSendMsgPkg{}
|
||||
return msgPkgs
|
||||
}
|
||||
|
||||
// 初始化仿真运行配置
|
||||
|
|
Loading…
Reference in New Issue