UNPKG

node-red-contrib-self-healing

Version:
141 lines (135 loc) 4.18 kB
<script type="text/javascript"> RED.nodes.registerType("sensor-compensate", { category: "SHEN", defaults: { name: { value: "" }, msghistory: { value: 10, required: true, validate: RED.validators.number(), }, timeout: { value: 5, required: true, validate: RED.validators.number(), }, strategy: { value: "last", required: true }, confidenceFormula: { value: "", required: false }, isActive: { value: true, required: true }, }, inputs: 1, outputs: 1, color: "#74b9ff", label: function () { return this.name || "compensate"; }, inputLabels: "number", outputLabels: ["msg"], icon: "status.png", align: "left", }); </script> <script type="text/html" data-template-name="sensor-compensate"> <div class="form-row"> <label for="node-input-name" ><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span ></label> <input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name" /> </div> <div class="form-row"> <label for="node-input-msghistory"> Message History </label> <input type="number" id="node-input-msghistory" placeholder="10" /> </div> <div class="form-row"> <label for="node-input-timeout"> Timeout (s) </label> <input type="number" id="node-input-timeout" step="0.01" placeholder="10.0" /> </div> <div class="form-row"> <label for="node-input-strategy"> Compensate Strategy </label> <select type="text" id="node-input-strategy"> <option>min</option> <option>max</option> <option>last</option> <option>mode</option> <option>mean</option> </select> </div> <p> Confidence does an eval of a valid JS expression. Both compensated values counter (_compensatedCounter) and history values (_history) can be used. Example: (1 / _compensatedCounter) >= 1 ? 1 : (1 / _compensatedCounter) </p> <div class="form-row"> <label for="node-input-confidenceFormula"> Confidence Formula </label> <input type="text" id="node-input-confidenceFormula" placeholder="compensatedCounter" /> </div> <div class="form-row"> <label for="node-input-isActive"> Is Active? </label> <input type="checkbox" id="node-input-isActive" checked="true" /> </div> </script> <script type="text/html" data-help-name="sensor-compensate"> <p>A node to compensate missing values with a pre-defined strategy.</p> <h3>Properties</h3> <dl class="message-properties"> <dt> name <span class="property-type">string</span> </dt> <dd>name of node to be displayed in editor.</dd> <dt> message history <span class="property-type">number</span> </dt> <dd> number of previous messages that the node uses in order to calculate the missing value. </dd> <dt>timeout<span class="property-type">number</span></dt> <dd>time before a message is considered missing</dd> <dt>strategy</dt> <dd>strategy the node will use to calculate the missing value.</dd> <dt>confidence formula</dt> <dd>formula that provides a confidence level on the compensated values.</dd> <dt>Is Active?</dt> <dd> Defines behaviour of compensate node as active or passive. If its disabled (unchecked) the compensate node will only trigger a compensated value if it recieves a message with the "trigger" key. </dd> </dl> <h3>Inputs</h3> <dl class="message-properties"> <p>Any input in which the payload is a number</p> </dl> <h3>Outputs</h3> <dl class="message-properties"> <p> If a new message arrives at the node before the designed timeout, the node will output that message. </p> <p> If not, it will output the value calculated through the defined strategy. </p> </dl> <h3>Details</h3> <p> This node is used to prevent the disruption of the message flow by compensating missing values with the ones that are calculated based on previous messages. </p> </script>