diff -r a098b2dd9dff -r 5823b73b132f svghmi/svghmi.js --- a/svghmi/svghmi.js Thu Dec 24 16:56:19 2020 +0100 +++ b/svghmi/svghmi.js Thu Dec 24 17:00:43 2020 +0100 @@ -267,21 +267,20 @@ const quotes = {"'":null, '"':null}; -function change_hmi_value(index, opstr) { +function eval_operation_string(old_val, opstr) { let op = opstr[0]; let given_val; if(opstr.length < 2) - return undefined; // TODO raise + return undefined; if(opstr[1] in quotes){ if(opstr.length < 3) - return undefined; // TODO raise + return undefined; if(opstr[opstr.length-1] == opstr[1]){ given_val = opstr.slice(2,opstr.length-1); } } else { given_val = Number(opstr.slice(1)); } - let old_val = cache[index]; let new_val; switch(op){ case "=": @@ -300,11 +299,19 @@ new_val = old_val / given_val; break; } + return new_val; +} + +/* +function change_hmi_value(index, opstr) { + let old_val = cache[index]; + let new_val = eval_operation_string(old_val, opstr); if(new_val != undefined && old_val != new_val) send_hmi_value(index, new_val); // TODO else raise return new_val; } +*/ var current_visible_page; var current_subscribed_page;