优化portId,提高兼容性

This commit is contained in:
boyce
2025-10-28 11:11:36 +08:00
parent f3ea9d7c7f
commit 969fbe818c
4 changed files with 50 additions and 22 deletions

View File

@@ -5,8 +5,8 @@ import (
)
type prePortNode struct {
node *execNode // 上个结点
outPortIndex int // 对应上一个结点的OutPort索引
node *execNode // 上个结点
outPortId int // 对应上一个结点的OutPortId
}
type execNode struct {
@@ -142,9 +142,9 @@ func (en *execNode) doSetInPort(gr *Graph, index int, inPort IPort) error {
// 判断上一个结点是否已经执行过
if _, ok := gr.context[preNode.node.Id]; ok {
outPort := gr.GetNodeOutPortValue(preNode.node.Id, preNode.outPortIndex)
outPort := gr.GetNodeOutPortValue(preNode.node.Id, preNode.outPortId)
if outPort == nil {
return fmt.Errorf("pre node %s out port index %d not found", preNode.node.Id, preNode.outPortIndex)
return fmt.Errorf("pre node %s out port index %d not found", preNode.node.Id, preNode.outPortId)
}
inPort.SetValue(outPort)
@@ -175,12 +175,12 @@ func (en *execNode) Do(gr *Graph, outPortArgs ...any) error {
// 处理InPort结点值
var err error
for index := range inPorts {
if en.execNode.IsInPortExec(index) {
for portId := range inPorts {
if en.execNode.IsInPortExec(portId) {
continue
}
err = en.doSetInPort(gr, index, inPorts[index])
err = en.doSetInPort(gr, portId, inPorts[portId])
if err != nil {
return err
}