优化蓝图执行器

This commit is contained in:
boyce
2025-10-30 16:00:46 +08:00
parent 21e9b2cd4b
commit 1995d91cfc
7 changed files with 40 additions and 58 deletions

View File

@@ -2,6 +2,7 @@ package blueprint
import (
"fmt"
"github.com/duanhf2012/origin/v2/log"
)
type prePortNode struct {
@@ -102,20 +103,6 @@ func (en *execNode) exec(gr *Graph) (int, error) {
return -1, err
}
//defer func() {
inPort, outPort := node.GetPorts()
debugString := "inPort:"
for i := 0; i < len(inPort); i++ {
debugString += fmt.Sprintf("%+v,", inPort[i])
}
debugString += " outPort:"
for i := 0; i < len(outPort); i++ {
debugString += fmt.Sprintf("%+v,", outPort[i])
}
fmt.Printf("exec node %s,%s\n", en.execNode.GetName(), debugString)
//}()
return e.Exec()
}
@@ -155,6 +142,10 @@ func (en *execNode) doSetInPort(gr *Graph, index int, inPort IPort) error {
}
func (en *execNode) Do(gr *Graph, outPortArgs ...any) error {
if IsDebug {
log.Debug("Start ExecNode", log.String("Name",en.execNode.GetName()))
}
// 重新初始化上下文
inPorts, outPorts := en.execNode.CloneInOutPort()
gr.context[en.Id] = &ExecContext{
@@ -194,6 +185,10 @@ func (en *execNode) Do(gr *Graph, outPortArgs ...any) error {
return err
}
if IsDebug {
log.Debug("End ExecNode", log.String("Name",en.execNode.GetName()),log.Any("InPort",inPorts ),log.Any("OutPort",outPorts))
}
if nextIndex == -1 || en.nextNode == nil {
return nil
}