Skip to content

Commit

Permalink
Fixes #29
Browse files Browse the repository at this point in the history
  • Loading branch information
slominskir committed Oct 11, 2022
1 parent 0a38545 commit d175356
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 18 deletions.
16 changes: 16 additions & 0 deletions examples/edl/wedm/tests/loc.edl
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,19 @@ newPos
objType "monitors"
endObjectProperties

# (Circle)
object activeCircleClass
beginObjectProperties
major 4
minor 0
release 0
x 5
y 127
w 12
h 12
lineColor index 14
lineWidth 1
fill
fillColor index 101
alarmPv CALC\\\{A||B\}(LOC\\V1=i:0,LOC\\V2=i:1)
endObjectProperties
18 changes: 17 additions & 1 deletion src/main/webapp/resources/js/screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,20 @@ jlab.wedm.PvObserver = function (id, pvSet) {

return pvs;
};

jlab.wedm.PvObserver.prototype.handleCalcExpr = function(value) {
if (jlab.wedm.isCalcExpr(this.pvSet.colorPvExpr)) {
var pvs = this.toOrderedExpressionValues(this.pvSet.colorPvs);

if(pvs == null) {
return null; // We don't have complete set of variables yet!
}

value = jlab.wedm.evalCalcExpr(this.pvSet.colorPvExpr, pvs);
}

return value;
};
};

jlab.wedm.isLocalExpr = function (expr) {
Expand Down Expand Up @@ -426,9 +440,11 @@ jlab.wedm.parseLocalVar = function (expr) {
} else {
local.value = 0;
}
} else if (type !== "s") { // if not enum or string must be integer or double
} else if (type !== "s") { // if not enum or string must be integer or double or byte
if (local.value === '') { // Default is zero for numbers
local.value = 0;
} else { // Convert str to number else CALC expressions with LOC vars break on logical or and such
local.value = local.value * 1;
}
}

Expand Down
19 changes: 16 additions & 3 deletions src/main/webapp/resources/widgets/activeRectangleClass/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,22 +84,35 @@ jlab.wedm.ShapePvObserverInit = function () {
color,
stmt,
lineRuleIndex = $obj.attr("data-line-color-rule"),
fillRuleIndex = $obj.attr("data-fill-color-rule");
fillRuleIndex = $obj.attr("data-fill-color-rule"),
value = update.value;

$obj[0].classList.remove("waiting-for-state");

if (lineRuleIndex !== undefined) {
stmt = jlab.wedm.colorRules[lineRuleIndex];

color = jlab.wedm.evalColorExpr.call(this, stmt, update.value);
value = this.handleCalcExpr(value);

if(value == null) {
return; // Still waiting for more updates
}

color = jlab.wedm.evalColorExpr.call(this, stmt, value);

$shape.attr("stroke", color);
}

if (fillRuleIndex !== undefined) {
stmt = jlab.wedm.colorRules[fillRuleIndex];

color = jlab.wedm.evalColorExpr.call(this, stmt, update.value);
value = this.handleCalcExpr(value);

if(value == null) {
return; // Still waiting for more updates
}

color = jlab.wedm.evalColorExpr.call(this, stmt, value);

$shape.attr("fill", color);
}
Expand Down
14 changes: 0 additions & 14 deletions src/main/webapp/resources/widgets/activeXTextClass/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,6 @@ jlab.wedm.StaticTextPvObserverInit = function () {
}
};

jlab.wedm.StaticTextPvObserver.prototype.handleCalcExpr = function(value) {
if (jlab.wedm.isCalcExpr(this.pvSet.colorPvExpr)) {
var pvs = this.toOrderedExpressionValues(this.pvSet.colorPvs);

if(pvs == null) {
return null; // We don't have complete set of variables yet!
}

value = jlab.wedm.evalCalcExpr(this.pvSet.colorPvExpr, pvs);
}

return value;
};

jlab.wedm.StaticTextPvObserver.prototype.handleColorUpdate = function (update) {
var $obj = $("#" + this.id),
color,
Expand Down

0 comments on commit d175356

Please sign in to comment.