Code Monkey home page Code Monkey logo

honcho's Introduction

honcho

Honcho is a multiple PLC connection manager for Node.JS using nodes7/nodepccc/mcprotocol or other libraries that use a similar API to those.

Normally Honcho will be called by a program that configures it and subscribes to its polls, like a server that streams PLC data over a Websocket or TCP stream.

Honcho is initially configured by a configuration object and multiple PLC tag files.

First create a tag to address translation file using a text editor:

testplctags.txt should have only one line for the following example to work: MYTAG=DB99,INT0

Example application:

var honcho = require('honcho');

config = {
	defaultController: 'TESTPLC',
	tagFileDir: '.',
	controllers: [
		{ host: '192.168.1.2',
		connection_name: 'TESTPLC',
		port: 102,
		slot: 1, 	/* See NodeS7 docs - slot 1 for 1200/1500, slot 2 for 300 */
		type: 'nodes7',
  			tagfile: './testplctags.txt' }
		],

	/* Define one or more tagsets to be subscribed to */
	tagsets: ['status'],

	/* Define one or more tags to be subscribed to */
	tags : {
		'MYTAG':{
		tagsets:['status']
		}		
	}
};

function readDone(err, vars) {
	console.log(vars);
	// Or stream to a Websocket, etc
}

honcho.configure(config, function(){
	honcho.createSubscription(['MYTAG'], readDone, 500);
});

This will log the following every 500ms:

{ MYTAG: 0 }

API

honcho.configure(config, callback)

Sets up the configuration and calls the callback when done. Please see above for configuration syntax.

honcho.findItem(item, callback)

Retuns the full "item" from the PLC driver in the callback.

honcho.read(tags, callback)

Reads specific tags and runs a callback with their values. Note the callback is called as callback(err, values).

honcho.write(tag, value, callback)

Writes a specific tag and runs an optional callback with the result.

honcho.createSubscription(tag array, callback, interval)

Sets up a subscription that will return the values of listed tags every timeout via the callback. Returns a token useful for removing subscriptions. Note the callback is called as callback(err, values).

honcho.removeSubscription(token)

Removes a subscription using a token returned when creating it.

honcho's People

Contributors

limeyd avatar loocat avatar plcpeople avatar

Watchers

 avatar  avatar

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.