From 75660bdec0ca68ec1c7a5d8a39cf5f8b683f2b26 Mon Sep 17 00:00:00 2001 From: boyce <6549168@qq.com> Date: Thu, 27 Nov 2025 09:15:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=BB=93=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- util/blueprint/blueprint.go | 2 ++ util/blueprint/graph.go | 11 +++++++ util/blueprint/sysnodes.go | 57 +++++++++++++++++++++++++++++++++++-- 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/util/blueprint/blueprint.go b/util/blueprint/blueprint.go index 38d1633..40e9587 100644 --- a/util/blueprint/blueprint.go +++ b/util/blueprint/blueprint.go @@ -69,6 +69,8 @@ func (bm *Blueprint) regSysNodes() { bm.RegisterExecNode(NewExecNode[EqualSwitch]()) bm.RegisterExecNode(NewExecNode[Probability]()) bm.RegisterExecNode(NewExecNode[CreateTimer]()) + bm.RegisterExecNode(NewExecNode[AppendIntReturn]()) + bm.RegisterExecNode(NewExecNode[AppendStringReturn]()) } diff --git a/util/blueprint/graph.go b/util/blueprint/graph.go index 6526043..5f91e7a 100644 --- a/util/blueprint/graph.go +++ b/util/blueprint/graph.go @@ -142,6 +142,17 @@ func (gc *graphConfig) GetNodeByID(nodeID string) *nodeConfig { return nil } +func (gr *Graph) GetAndCreateReturnPort() IPort { + p, ok := gr.globalVariables[ReturnVarial] + if ok { + return p + } + + p = NewPortArray() + gr.globalVariables[ReturnVarial] = p + return p +} + func (gr *Graph) Do(entranceID int64, args ...any) (Port_Array, error) { if IsDebug { log.Debug("Graph Do", log.String("graphName", gr.graphFileName), log.Int64("graphID", gr.graphID), log.Int64("entranceID", entranceID)) diff --git a/util/blueprint/sysnodes.go b/util/blueprint/sysnodes.go index bac66b5..4381dee 100644 --- a/util/blueprint/sysnodes.go +++ b/util/blueprint/sysnodes.go @@ -681,7 +681,7 @@ func (em *CreateTimer) Exec() (int, error) { array, ok := em.GetInPortArray(1) if !ok { - return -1, fmt.Errorf("CreateTimer inParam 0 error") + return -1, fmt.Errorf("CreateTimer inParam 1 error") } var timerId uint64 @@ -718,7 +718,7 @@ func (em *CloseTimer) GetName() string { func (em *CloseTimer) Exec() (int, error) { timerID, ok := em.GetInPortInt(1) if !ok { - return -1, fmt.Errorf("CreateTimer inParam 0 error") + return -1, fmt.Errorf("CreateTimer inParam 1 error") } id := uint64(timerID) @@ -729,3 +729,56 @@ func (em *CloseTimer) Exec() (int, error) { return 0, nil } + + + + +// AppendIntReturn 追加返回结果(Int) +type AppendIntReturn struct { + BaseExecNode +} + +func (em *AppendIntReturn) GetName() string { + return "AppendIntReturn" +} + +func (em *AppendIntReturn) Exec() (int, error) { + val, ok := em.GetInPortInt(1) + if !ok { + return -1, fmt.Errorf("AppendIntReturn inParam 1 error") + } + + returnPort := em.gr.GetAndCreateReturnPort() + if returnPort == nil { + return -1, fmt.Errorf("GetAndCreateReturnPort fail") + } + returnPort.AppendArrayValInt(val) + + return -0, nil +} + + + +// AppendStringReturn 追加返回结果(String) +type AppendStringReturn struct { + BaseExecNode +} + +func (em *AppendStringReturn) GetName() string { + return "AppendStringReturn" +} + +func (em *AppendStringReturn) Exec() (int, error) { + val, ok := em.GetInPortStr(1) + if !ok { + return -1, fmt.Errorf("AppendStringReturn inParam 1 error") + } + + returnPort := em.gr.GetAndCreateReturnPort() + if returnPort == nil { + return -1, fmt.Errorf("GetAndCreateReturnPort fail") + } + returnPort.AppendArrayValStr(val) + + return -0, nil +} \ No newline at end of file