node-red-contrib-vban
Version:
Nodes to interact with vban protocol
44 lines (43 loc) • 1.39 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Node = void 0;
const TechnicalNode_1 = require("./TechnicalNode");
const ENodeStatus_1 = require("./ENodeStatus");
class Node extends TechnicalNode_1.TechnicalNode {
setStatus(status, text) {
let nodeStatus;
switch (status) {
case ENodeStatus_1.ENodeStatus.PENDING:
nodeStatus = {
fill: 'yellow',
shape: 'ring'
};
break;
case ENodeStatus_1.ENodeStatus.READY:
nodeStatus = {
fill: 'green',
shape: 'dot'
};
break;
case ENodeStatus_1.ENodeStatus.ERROR:
nodeStatus = {
fill: 'red',
shape: 'dot'
};
break;
case ENodeStatus_1.ENodeStatus.RESET:
default:
nodeStatus = {};
break;
}
if (text && status !== ENodeStatus_1.ENodeStatus.RESET) {
nodeStatus.text = text;
}
this.lastStatus = Object.assign(Object.assign({}, nodeStatus), { status });
this.node.status(nodeStatus);
}
send(msg, sendFn) {
(sendFn || this.node.send.bind(this.node))(msg);
}
}
exports.Node = Node;