Dia antes primera install
This commit is contained in:
59
node_modules/node-red-contrib-sm-16inpind/16inpind.html
generated
vendored
Normal file
59
node_modules/node-red-contrib-sm-16inpind/16inpind.html
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<script type="text/html" data-template-name="16inpind">
|
||||
<div class="form-row">
|
||||
<label for="node-input-stack"><i class="fa fa-address-card-o""></i> Board Stack Level</label>
|
||||
<input id="node-input-stack" class="16inpind-in-stack" placeholder="[msg.stack]" min=0 max=7 style="width:100px; height:16px;">
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-channel"><i class="fa fa-empire"></i> Channel Number</label>
|
||||
<input id="node-input-channel" class="16inpind-in-channel" placeholder="[msg.channel]" min=0 max=16 style="width:100px; height:16px;">
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
||||
<input type="text" id="node-input-name" placeholder="Name">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" data-help-name="16inpind">
|
||||
<p>Provides a connection to an Sequent Microsystems 16-Inputs card.</p>
|
||||
<p>Each message received by the node generate a <code>msg.payload</code> with the state of one channel from 16 or a bitmap of all channels if the selected <code> channel </code> is 0 </p>
|
||||
<p>You can specify the card stack level in the edit dialog box or programaticaly with the input message <code>msg.stack</code></p>
|
||||
<p>You can specify the channel number in the edit dialog box or programaticaly with the input message <code>msg.channel</code></p>
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
RED.nodes.registerType('16inpind', {
|
||||
category: 'Sequent Microsystems',
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
stack: {value:"0"},
|
||||
channel: {value:"1"},
|
||||
},
|
||||
color:"#7a9da6",
|
||||
inputs:1,
|
||||
outputs:1,
|
||||
icon: "optocoupler.png",
|
||||
align: "left",
|
||||
label: function() { return this.name||'16inpind'; },
|
||||
labelStyle: function() { return this.name?"node_label_italic":"";},
|
||||
oneditprepare: function() {
|
||||
|
||||
if (this.stack === undefined) {
|
||||
$("#node-input-stack").val(1);
|
||||
}
|
||||
$("#node-input-stack").spinner({
|
||||
min:0,
|
||||
max:7
|
||||
});
|
||||
if (this.channel === undefined) {
|
||||
$("#node-input-channel").val(1);
|
||||
}
|
||||
$("#node-input-channel").spinner({
|
||||
min:0,
|
||||
max:16
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
100
node_modules/node-red-contrib-sm-16inpind/16inpind.js
generated
vendored
Normal file
100
node_modules/node-red-contrib-sm-16inpind/16inpind.js
generated
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
module.exports = function(RED) {
|
||||
"use strict";
|
||||
var I2C = require("i2c-bus");
|
||||
const DEFAULT_HW_ADD = 0x20;
|
||||
const IN_REG = 0x00;
|
||||
const mask = new ArrayBuffer(16);
|
||||
mask[0] = 0x8000;
|
||||
mask[1] = 0x4000;
|
||||
mask[2] = 0x2000;
|
||||
mask[3] = 0x1000;
|
||||
mask[4] = 0x0800;
|
||||
mask[5] = 0x0400;
|
||||
mask[6] = 0x0200;
|
||||
mask[7] = 0x0100;
|
||||
mask[8] = 0x80;
|
||||
mask[9] = 0x40;
|
||||
mask[10] = 0x20;
|
||||
mask[11] = 0x10;
|
||||
mask[12] = 0x08;
|
||||
mask[13] = 0x04;
|
||||
mask[14] = 0x02;
|
||||
mask[15] = 0x01;
|
||||
|
||||
// The Opto input read Node
|
||||
function OptoInputNode(n) {
|
||||
RED.nodes.createNode(this, n);
|
||||
this.stack = parseInt(n.stack);
|
||||
this.channel = parseInt(n.channel);
|
||||
this.payload = n.payload;
|
||||
this.payloadType = n.payloadType;
|
||||
var node = this;
|
||||
|
||||
node.port = I2C.openSync( 1 );
|
||||
node.on("input", function(msg) {
|
||||
var myPayload;
|
||||
var stack = node.stack;
|
||||
if (isNaN(stack)) stack = msg.stack;
|
||||
stack = parseInt(stack);
|
||||
var channel = node.channel;
|
||||
if (isNaN(channel)) channel = msg.channel;
|
||||
channel = parseInt(channel);
|
||||
|
||||
if (isNaN(stack + 1)) {
|
||||
this.status({fill:"red",shape:"ring",text:"Stack level ("+stack+") value is missing or incorrect"});
|
||||
return;
|
||||
} else if (isNaN(channel) ) {
|
||||
this.status({fill:"red",shape:"ring",text:"Relay number ("+channel+") value is missing or incorrect"});
|
||||
return;
|
||||
} else {
|
||||
this.status({});
|
||||
}
|
||||
var hwAdd = DEFAULT_HW_ADD;
|
||||
if(stack < 0){
|
||||
stack = 0;
|
||||
}
|
||||
if(stack > 7){
|
||||
stack = 7;
|
||||
}
|
||||
//check the type of io_expander
|
||||
hwAdd += stack ^ 0x07;
|
||||
var rawData = 0x0000;
|
||||
try{
|
||||
rawData = node.port.readWordSync(hwAdd, IN_REG );
|
||||
|
||||
if(channel < 0){
|
||||
channel = 0;
|
||||
}
|
||||
if(channel > 16){
|
||||
channel = 16;
|
||||
}
|
||||
if( channel > 0){
|
||||
channel-= 1;//zero based
|
||||
rawData = ~rawData;
|
||||
if( (rawData & mask[channel]) != 0){
|
||||
msg.payload = 1;
|
||||
}else{
|
||||
msg.payload = 0;
|
||||
}
|
||||
}else{
|
||||
var optoData = 0x0000;
|
||||
var idx = 0;
|
||||
rawData = ~rawData;
|
||||
for(idx = 0; idx < 16; idx++){
|
||||
if( (rawData & mask[idx]) != 0){
|
||||
optoData += 1 << idx;
|
||||
}
|
||||
}
|
||||
msg.payload = optoData;
|
||||
}
|
||||
node.send(msg);
|
||||
}catch(err) {
|
||||
this.error(err,msg);
|
||||
}
|
||||
});
|
||||
node.on("close", function() {
|
||||
node.port.closeSync();
|
||||
});
|
||||
}
|
||||
RED.nodes.registerType("16inpind", OptoInputNode);
|
||||
}
|
||||
20
node_modules/node-red-contrib-sm-16inpind/LICENSE
generated
vendored
Normal file
20
node_modules/node-red-contrib-sm-16inpind/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2029 Sequent Microsystems
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
35
node_modules/node-red-contrib-sm-16inpind/README.md
generated
vendored
Normal file
35
node_modules/node-red-contrib-sm-16inpind/README.md
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# node-red-contrib-sm-16inpind
|
||||
|
||||
This is the node-red node to control Sequent Microsystems [16-INPUTS Stackable Card for Raspberry Pi](https://sequentmicrosystems.com/collections/all-io-cards/products/16-universal-inputs-3-48vac-dc-8-layer-stackable-card-br-for-raspberry-pi).
|
||||
|
||||
## Manual Install
|
||||
|
||||
Clone or update the repository, follow the instructions from the [first page.](https://github.com/SequentMicrosystems/16inpind-rpi)
|
||||
|
||||
In your node-red user directory, typically ~/.node-red,
|
||||
|
||||
```bash
|
||||
~$ cd ~/.node-red
|
||||
```
|
||||
|
||||
Run the following command:
|
||||
|
||||
```bash
|
||||
~/.node-red$ npm install ~/16inpind-rpi/node-red-contrib-sm-16inpind
|
||||
```
|
||||
|
||||
To see the node in the palette and use it you need to restart node-red. If you run node-red as a service:
|
||||
```bash
|
||||
~$ node-red-stop
|
||||
~$ node-red-start
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
After installing and restarting the node-red you will see on the node palette, under the Sequent Microsystems category the "16inpind" node.
|
||||
This node will output the state of one of 16 inputs if the ```channel``` parameter is between 1 and 16 including. The node will output a bitmap of all 16 inputs if the ```channel``` parameter is 0.
|
||||
The card stack level and channel number can be set in the dialog screen or dynamically thru ``` msg.stack``` and ``` msg.channel ```.
|
||||
## Important note
|
||||
|
||||
This node is using the I2C-bus package from @fivdi, you can visit his work on GitHub [here](https://github.com/fivdi/i2c-bus).
|
||||
The inspiration for this node came from @nielsnl68 work with [node-red-contrib-i2c](https://github.com/nielsnl68/node-red-contrib-i2c).Thank you both for a great job.
|
||||
BIN
node_modules/node-red-contrib-sm-16inpind/icons/optocoupler.png
generated
vendored
Normal file
BIN
node_modules/node-red-contrib-sm-16inpind/icons/optocoupler.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
32
node_modules/node-red-contrib-sm-16inpind/package.json
generated
vendored
Normal file
32
node_modules/node-red-contrib-sm-16inpind/package.json
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "node-red-contrib-sm-16inpind",
|
||||
"version": "1.0.1",
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"i2c-bus": "^5.2.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "A Node-RED node to control Sequent Microsystems 16Inputs board",
|
||||
"main": "16inpind.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Sequent Microsystems",
|
||||
"license": "MIT",
|
||||
"node-red" : {
|
||||
"nodes": {
|
||||
"16inputs": "16inpind.js"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/SequentMicrosystems/16inpind-rpi/tree/main/node-red-contrib-sm-16inpind"
|
||||
},
|
||||
"keywords": [
|
||||
"node-red",
|
||||
"node-red-contrib",
|
||||
"i2c",
|
||||
"opto",
|
||||
"digital"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user