mirror of
https://github.com/duanhf2012/origin.git
synced 2026-03-15 13:27:32 +08:00
优化蓝图
This commit is contained in:
@@ -71,6 +71,7 @@ func (bm *Blueprint) regSysNodes() {
|
|||||||
bm.RegisterExecNode(NewExecNode[CreateTimer]())
|
bm.RegisterExecNode(NewExecNode[CreateTimer]())
|
||||||
bm.RegisterExecNode(NewExecNode[AppendIntReturn]())
|
bm.RegisterExecNode(NewExecNode[AppendIntReturn]())
|
||||||
bm.RegisterExecNode(NewExecNode[AppendStringReturn]())
|
bm.RegisterExecNode(NewExecNode[AppendStringReturn]())
|
||||||
|
bm.RegisterExecNode(NewExecNode[IntInArray]())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -780,5 +780,37 @@ func (em *AppendStringReturn) Exec() (int, error) {
|
|||||||
}
|
}
|
||||||
returnPort.AppendArrayValStr(val)
|
returnPort.AppendArrayValStr(val)
|
||||||
|
|
||||||
|
return -0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// IntInArray 判断整型值是否在整型数组中
|
||||||
|
type IntInArray struct {
|
||||||
|
BaseExecNode
|
||||||
|
}
|
||||||
|
|
||||||
|
func (em *IntInArray) GetName() string {
|
||||||
|
return "IntInArray"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (em *IntInArray) Exec() (int, error) {
|
||||||
|
val, ok := em.GetInPortInt(1)
|
||||||
|
if !ok {
|
||||||
|
return -1, fmt.Errorf("IntInArray inParam 1 not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
array, ok := em.GetInPortArray(2)
|
||||||
|
if !ok {
|
||||||
|
return -1, fmt.Errorf("IntInArray inParam 0 not found")
|
||||||
|
}
|
||||||
|
|
||||||
|
bFind := false
|
||||||
|
for i := range array {
|
||||||
|
if array[i].IntVal == val {
|
||||||
|
bFind = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
em.SetOutPortBool(1,bFind)
|
||||||
return -0, nil
|
return -0, nil
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user