Sensor calibration on "constant-step" function

  1. Sensor calibration on step function

Sometimes it is necessary to convert a sensor value into a simpler "constant step" function. For example, to display the percentage of vehicle loading. An example implementation of the solution using the script below:


.module Declare
Attr Integer IO333 "Sensor";
Attr Integer CARGO "Cargo%";
.module onMessage
// ignore values < 20 and > 380
String scargo = getStringByVal( getIntAttr("IO333"),"< 20 *","< 100 20","< 200 50","< 300 80","< 380 100",">= 380 *");
if (scargo!=null && !scargo.equals("*")) {
  CARGO = Integer.parseInt(scargo);
}
Back Directory

top