Ladder Logic Compiler for node.js and the web
npm install ladder-logicThis node.js package provides methods for compiling and decompiling ladder logic programs.
- Installation
- ll.compile
- ll.decompile
```
npm install git+https://github.com/bakerface/ll.git
` javascript
var ll = require("ll");
var program = ll.compile(
"!! this is an example of a latch with an emergency stop !!\n" +
"||--[/ESTOP]----[/STOP]----+--[START]--+------(RUN)-----||\n" +
"|| | | ||\n" +
"|| +---[RUN]---+ ||\n" +
"|| ||\n" +
"||--[RUN]-------------------------------------(MOTOR)---||");
console.log(program);
/*
[ [ 'in', 'ESTOP' ],
[ 'not' ],
[ 'in', 'STOP' ],
[ 'not' ],
[ 'and' ],
[ 'in', 'START' ],
[ 'in', 'RUN' ],
[ 'or' ],
[ 'and' ],
[ 'out', 'RUN' ],
[ 'in', 'RUN' ],
[ 'out', 'MOTOR' ] ]
*/
`
` javascript
var ll = require("ll");
var program = [
[ 'in', 'ESTOP' ],
[ 'not' ],
[ 'in', 'STOP' ],
[ 'not' ],
[ 'and' ],
[ 'in', 'START' ],
[ 'in', 'RUN' ],
[ 'or' ],
[ 'and' ],
[ 'out', 'RUN' ],
[ 'in', 'RUN' ],
[ 'out', 'MOTOR' ]
];
console.log(ll.decompile(program));
/*
|| ||
||--[/ESTOP]----[/STOP]----+--[START]--+----(RUN)--||
|| | | ||
|| +--[RUN]----+ ||
|| ||
||--[RUN]----(MOTOR)-------------------------------||
|| ||
*/
``