diff --git a/util/blueprint/blueprint.go b/util/blueprint/blueprint.go index 9770098..59257c5 100644 --- a/util/blueprint/blueprint.go +++ b/util/blueprint/blueprint.go @@ -71,6 +71,7 @@ func (bm *Blueprint) regSysNodes() { bm.RegisterExecNode(NewExecNode[CreateTimer]()) bm.RegisterExecNode(NewExecNode[AppendIntReturn]()) bm.RegisterExecNode(NewExecNode[AppendStringReturn]()) + bm.RegisterExecNode(NewExecNode[IntInArray]()) } diff --git a/util/blueprint/sysnodes.go b/util/blueprint/sysnodes.go index 4381dee..add71c8 100644 --- a/util/blueprint/sysnodes.go +++ b/util/blueprint/sysnodes.go @@ -780,5 +780,37 @@ func (em *AppendStringReturn) Exec() (int, error) { } 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 } \ No newline at end of file