From 76935afa8ac8f86237888fe63475ed9827f15570 Mon Sep 17 00:00:00 2001 From: Kirill Shumilov Date: Fri, 23 Nov 2018 17:53:09 +0300 Subject: [PATCH] fix(xod/core): fix `xod/core/delta` to work just like before adding pulses into tabtests --- workspace/__lib__/xod/core/delta/patch.cpp | 9 +++++---- .../__lib__/xod/core/delta/patch.test.tsv | 18 +++++++++--------- workspace/__lib__/xod/core/delta/patch.xodp | 10 +++++----- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/workspace/__lib__/xod/core/delta/patch.cpp b/workspace/__lib__/xod/core/delta/patch.cpp index cc4f44e7..9fccc80c 100644 --- a/workspace/__lib__/xod/core/delta/patch.cpp +++ b/workspace/__lib__/xod/core/delta/patch.cpp @@ -12,15 +12,16 @@ void evaluate(Context ctx) { auto inValue = getValue(ctx); if (isInputDirty(ctx)) { - state->refValue = 0; - emitValue(ctx, inValue); + state->refValue = inValue; + emitValue(ctx, 0); return; } - if (isInputDirty(ctx)) { - state->refValue = inValue; + if (!isInputDirty(ctx)) { + return; } auto outValue = inValue - state->refValue; emitValue(ctx, outValue); + state->refValue = inValue; } diff --git a/workspace/__lib__/xod/core/delta/patch.test.tsv b/workspace/__lib__/xod/core/delta/patch.test.tsv index 99c1b7a6..33ec8b9f 100644 --- a/workspace/__lib__/xod/core/delta/patch.test.tsv +++ b/workspace/__lib__/xod/core/delta/patch.test.tsv @@ -1,10 +1,10 @@ -IN BIAS RST OUT +IN UPD RST OUT 0 no-pulse no-pulse 0 -10 pulse no-pulse 0 -30 no-pulse no-pulse 20 -0 no-pulse no-pulse -10 -20 no-pulse pulse 20 -10 no-pulse no-pulse 10 -10 pulse no-pulse 0 -10 pulse pulse 10 -50 no-pulse no-pulse 50 +10 pulse no-pulse 10 +30 no-pulse no-pulse 10 +20 no-pulse pulse 0 +30 pulse no-pulse 10 +50 pulse no-pulse 20 +10 pulse no-pulse -40 +10 pulse pulse 0 +5 pulse no-pulse -5 diff --git a/workspace/__lib__/xod/core/delta/patch.xodp b/workspace/__lib__/xod/core/delta/patch.xodp index b6708a5e..d89c4129 100644 --- a/workspace/__lib__/xod/core/delta/patch.xodp +++ b/workspace/__lib__/xod/core/delta/patch.xodp @@ -1,5 +1,5 @@ { - "description": "Outputs a difference between the current `IN` value and its reference value.", + "description": "Calculates difference between current and past input values.", "nodes": [ { "id": "HyJCAXqNG", @@ -10,9 +10,9 @@ "type": "xod/patch-nodes/not-implemented-in-xod" }, { - "description": "Triggers memoization of the input value as the reference value.", + "description": "Update: trigger a calculation and store the current `IN` value as the new “past” value.", "id": "S1bhCQqVM", - "label": "REF", + "label": "UPD", "position": { "x": 102, "y": 0 @@ -20,7 +20,7 @@ "type": "xod/patch-nodes/input-pulse" }, { - "description": "The difference between `IN` and the reference value which was stored when `REF` received a pulse. Can be positive or negative. Always equals to 0 on the first update.", + "description": "The last difference value.", "id": "SkFpRm9Nz", "position": { "x": 34, @@ -29,7 +29,7 @@ "type": "xod/patch-nodes/output-number" }, { - "description": "Resets the reference value to 0.", + "description": "Resets the stored past value to the current input value. Efficiently sets `OUT` to 0.", "id": "SyYn0X5NM", "label": "RST", "position": {