https://github.com/bakerface/ll
Ladder Logic Compiler for node.js and the web
https://github.com/bakerface/ll
Last synced: 7 months ago
JSON representation
Ladder Logic Compiler for node.js and the web
- Host: GitHub
- URL: https://github.com/bakerface/ll
- Owner: bakerface
- License: mit
- Created: 2014-02-16T03:41:03.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2014-11-18T13:48:53.000Z (over 11 years ago)
- Last Synced: 2025-09-21T13:30:41.702Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 242 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Ladder Logic Compiler
This node.js package provides methods for compiling and decompiling ladder logic programs.
## Table of Contents
- [Installation](#installation)
- [ll.compile](#llcompile)
- [ll.decompile](#lldecompile)
## Installation
To install this application using the node.js package manager, issue the following commands:
```
npm install ladder-logic
```
## *ll.compile*
Below is an example of how to use the compiler.
``` javascript
var ll = require("ladder-logic");
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' ] ]
*/
```
## *ll.decompile*
Below is an example of how to use the decompiler.
``` javascript
var ll = require("ladder-logic");
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)-------------------------------||
|| ||
*/
```