This modules sanitizes a composite of boolean plc signals that represent a state into one single variable.
It enables the developer to register for state changes by providing an event emitter.
let plcSignalSanitizer = require('plc-signal-sanitizer');
let trafficLights = new plcSignalSanitizer(["red", "green"]);
trafficLights.eventEmitter("sanitized", (state) => {
console.log("received new state: " + state);
})
trafficLights.changePlcSignal("red", true);
console.log(trafficLights.currentState;
trafficLights.changePlcSignal("red", false);
console.log(trafficLights.currentState);
console.log(trafficLights.lastGoodState);
trafficLights.changePlcSignal("green", true);
console.log(trafficLights.currentState);