Coder Social home page Coder Social logo

ll's Introduction

Ladder Logic Compiler

This node.js package provides methods for compiling and decompiling ladder logic programs.

Table of Contents

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.

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.

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)-------------------------------||
||                                                 ||
*/

ll's People

Contributors

bakerface avatar

Stargazers

Liam Gray avatar  avatar Chao Lu avatar Hiperión avatar wuyudian_1@163.com avatar Jason Wilson avatar Sirius Wu avatar Guilherme Francescon avatar Adam Cook avatar

Watchers

James Cloos avatar  avatar wuyudian_1@163.com avatar

Forkers

edsnet

ll's Issues

Overrides other node

[ [ 'in', 'A' ],
[ 'in', 'B' ],
[ 'in', 'E' ],
[ 'in', 'G' ],
[ 'or' ],
[ 'and' ],
[ 'or' ],
[ 'in', 'H' ],
[ 'or' ],
[ 'out', 'F' ] ]

Will decompile to following
screen shot 2018-03-18 at 8 38 16 pm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.