新增结点

This commit is contained in:
boyce
2025-10-22 16:13:03 +08:00
parent 08effd5bca
commit 70389b644d

View File

@@ -2,9 +2,10 @@ package blueprint
import ( import (
"fmt" "fmt"
"github.com/duanhf2012/origin/v2/log"
"math/rand/v2" "math/rand/v2"
"time" "time"
"github.com/duanhf2012/origin/v2/log"
) )
// 系统入口ID定义1000以内 // 系统入口ID定义1000以内
@@ -21,6 +22,8 @@ func init() {
RegExecNode(&Output{}) RegExecNode(&Output{})
RegExecNode(&Sequence{}) RegExecNode(&Sequence{})
RegExecNode(&Foreach{}) RegExecNode(&Foreach{})
RegExecNode(&ForeachIntArray{})
RegExecNode(&GetArrayInt{}) RegExecNode(&GetArrayInt{})
RegExecNode(&GetArrayString{}) RegExecNode(&GetArrayString{})
RegExecNode(&GetArrayLen{}) RegExecNode(&GetArrayLen{})
@@ -125,6 +128,36 @@ func (em *Sequence) Exec() (int, error) {
return -1, nil return -1, nil
} }
type ForeachIntArray struct {
BaseExecNode
}
func (em *ForeachIntArray) GetName() string {
return "ForeachIntArray"
}
func (em *ForeachIntArray) Exec() (int, error) {
array, ok := em.GetInPortArray(1)
if !ok {
return 0, fmt.Errorf("ForeachIntArray Exec inParam 1 not found")
}
for i := range array {
em.ExecContext.OutputPorts[2].SetInt(array[i].IntVal)
err := em.DoNext(0)
if err != nil {
return -1, err
}
}
err := em.DoNext(1)
if err != nil {
return -1, err
}
return -1, nil
}
type Foreach struct { type Foreach struct {
BaseExecNode BaseExecNode
} }
@@ -649,8 +682,8 @@ func (em *CreateTimer) Exec() (int, error) {
if err != nil { if err != nil {
log.Warnf("CreateTimer SafeAfterFunc error timerId:%d err:%v", timerId, err) log.Warnf("CreateTimer SafeAfterFunc error timerId:%d err:%v", timerId, err)
} }
em.gr.IBlueprintModule.CancelTimerId(graphID,&timerId) em.gr.IBlueprintModule.CancelTimerId(graphID, &timerId)
}) })
em.gr.mapTimerID[timerId] = struct{}{} em.gr.mapTimerID[timerId] = struct{}{}