mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
新增结点
This commit is contained in:
@@ -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]())
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user