优化代码

This commit is contained in:
boyce
2025-09-23 10:20:03 +08:00
parent 3bcce31a86
commit 77e2986ffb
8 changed files with 181 additions and 37 deletions

View File

@@ -1,6 +1,7 @@
package blueprint
import (
"fmt"
"testing"
)
@@ -16,11 +17,33 @@ func (em *Entrance_IntParam) Exec() (int, error) {
return 0, nil
}
type Output struct {
BaseExecNode
}
func (em *Output) GetName() string {
return "Output"
}
func (em *Output) Exec() (int, error) {
val, ok := em.GetInPortInt(0)
if !ok {
return 0, fmt.Errorf("Output Exec inParam not found")
}
fmt.Printf("Output Exec inParam %d", val)
return 0, nil
}
func OnRegister(bm *ExecPool) error {
bm.Register(&Entrance_IntParam{})
bm.Register(&Output{})
return nil
}
const (
EntranceID_IntParam = 3
)
func TestExecMgr(t *testing.T) {
//
var bp Blueprint
@@ -28,4 +51,13 @@ func TestExecMgr(t *testing.T) {
if err != nil {
t.Fatalf("init failed,err:%v", err)
}
graph := bp.Create("test1")
err = graph.Do(EntranceID_IntParam, 1, 2, 3)
if err != nil {
t.Fatalf("do failed,err:%v", err)
}
graph.Release()
}