function-if

samele1222/ship-data/function-if

function-if
@/function-if
IN1number
CONDnumber
[...0...1....2....3....4.....5....] {...>...>=...<...<=...==...!=...}
IN2number
IFnumber
ELSEnumber
function-if
IN1
COND
IN2
IF
ELSE
OUT
OUTnumber
To use the node in your project you should have the samele1222/ship-data library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

struct State {
};

{{ GENERATED_CODE }}

void evaluate(Context ctx) {
    auto inValue = getValue<input_IN1>(ctx);
    auto Value = getValue<input_IN2>(ctx);
    auto ValIf = getValue<input_IF>(ctx);
    auto ValElse = getValue<input_ELSE>(ctx);
    uint8_t ValCond = getValue<input_COND>(ctx);
    uint32_t val;
    
    switch(ValCond){
        case 0:
            val = (inValue>Value)? ValIf : ValElse;
            break;
        case 1:
            val = (inValue<Value)? ValIf : ValElse;
            break;
        case 2:
            val = (inValue>=Value)? ValIf : ValElse;
            break;
        case 3:
            val = (inValue<=Value)? ValIf : ValElse;
            break;
        case 4:
            val = (inValue==Value)? ValIf : ValElse;
            break;
        case 5:
            val = (inValue!=Value)? ValIf : ValElse;
            break;
    }
    emitValue<output_OUT>(ctx, val);
}