1.1.0 • Published 5 years ago

plc-state-sanitizer v1.1.0

Weekly downloads
1
License
ISC
Repository
gitlab
Last release
5 years ago

PLC state sanitizer

pipeline status coverage report

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.

Usage

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;   // prints 'red'

trafficLights.changePlcSignal("red", false);
console.log(trafficLights.currentState);  // prints '😱 undefined'
console.log(trafficLights.lastGoodState); // prints 'red'

trafficLights.changePlcSignal("green", true);
console.log(trafficLights.currentState);  // prints 'green'
1.1.0

5 years ago

1.0.0

5 years ago