-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new flex connector the send connection data to the connector vi…
…a events #44
- Loading branch information
Showing
8 changed files
with
235 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"opcua-iiot-contrib": { | ||
"label": { | ||
"connector": "Connector", | ||
"showActivities": "Show Activities", | ||
"showErrors": "Show Errors" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<!-- | ||
The BSD 3-Clause License | ||
Copyright 2018 - Klaus Landsdorf (http://bianco-royal.de/) | ||
All rights reserved. | ||
node-red-contrib-iiot-opcua | ||
--> | ||
|
||
<script type="text/javascript"> | ||
RED.nodes.registerType('OPCUA-IIoT-Flex-Connector', { | ||
category: 'IIoT', | ||
color: '#ABCDEF', | ||
defaults: { | ||
name: {value: ''}, | ||
showStatusActivities: {value: false}, | ||
showErrors: {value: false}, | ||
connector: {type: 'OPCUA-IIoT-Connector', required: true} | ||
}, | ||
inputs: 1, | ||
outputs: 1, | ||
align: 'left', | ||
icon: 'icon.png', | ||
label: function () { | ||
return this.name || 'Flex Connector' | ||
}, | ||
labelStyle: function () { | ||
return this.name ? 'node_label_italic' : '' | ||
}, | ||
oneditprepare: function () { | ||
let node = this | ||
} | ||
}) | ||
</script> | ||
|
||
<script type="text/x-red" data-template-name="OPCUA-IIoT-Flex-Connector"> | ||
<div class="form-row"> | ||
<label for="node-input-connector"><i class="icon-tasks"></i> <span data-i18n="opcua-iiot-contrib.label.connector"></span></label> | ||
<input type="text" id="node-input-connector" placeholder="opc.tcp://localhost:4334"> | ||
</div> | ||
<div class="form-row"> | ||
<label for="node-input-name"><i class="icon-tag"></i> <span data-i18n="node-red:common.label.name"></span></label> | ||
<input type="text" id="node-input-name" placeholder=""> | ||
</div> | ||
<hr> | ||
<div class="form-row"> | ||
<label style="min-width:160px" for="node-input-showStatusActivities"><i class="fa fa-th"></i> | ||
<span data-i18n="opcua-iiot-contrib.label.showActivities"></span></label> | ||
<input type="checkbox" id="node-input-showStatusActivities" style="max-width:30px"> | ||
</div> | ||
<div class="form-row"> | ||
<label style="min-width:160px" for="node-input-showErrors"><i class="fa fa-th"></i> | ||
<span data-i18n="opcua-iiot-contrib.label.showErrors"></span></label> | ||
<input type="checkbox" id="node-input-showErrors" style="max-width:30px"> | ||
</div> | ||
</script> | ||
|
||
<script type="text/x-red" data-help-name="OPCUA-IIoT-Flex-Connector"> | ||
<h2>OPC UA IIoT Flex Connector</h2> | ||
|
||
<p> | ||
The Flex Connector node is to set up an event listener with parameters to change a connectors options. | ||
It is to trigger by an Inject of Node-RED or by the OPC UA IIoT Inject. | ||
It could also trigger with incoming events from other nodes. | ||
</p> | ||
|
||
<h3>Input</h3> | ||
|
||
<p>msg with connector parameters</p> | ||
|
||
<h3>Output</h3> | ||
|
||
<p>msg with connector parameters and result</p> | ||
|
||
<strong>Name</strong> | ||
<p>Name in the flow of Node-RED.</p> | ||
|
||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
The BSD 3-Clause License | ||
Copyright 2018 - Klaus Landsdorf (http://bianco-royal.de/) | ||
All rights reserved. | ||
node-red-contrib-iiot-opcua | ||
*/ | ||
'use strict' | ||
|
||
/** | ||
* Event Node-RED node. | ||
* | ||
* @param RED | ||
*/ | ||
module.exports = function (RED) { | ||
// SOURCE-MAP-REQUIRED | ||
let coreConnector = require('./core/opcua-iiot-core-connector') | ||
|
||
function OPCUAIIoTFlexConnector (config) { | ||
RED.nodes.createNode(this, config) | ||
this.name = config.name | ||
this.showStatusActivities = config.showStatusActivities | ||
this.showErrors = config.showErrors | ||
this.connector = RED.nodes.getNode(config.connector) | ||
|
||
let node = this | ||
|
||
node.status({fill: 'blue', shape: 'ring', text: 'new'}) | ||
|
||
node.statusLog = function (logMessage) { | ||
if (RED.settings.verbose && node.showStatusActivities) { | ||
node.verboseLog('Status: ' + logMessage) | ||
} | ||
} | ||
|
||
node.setNodeStatusTo = function (statusValue) { | ||
node.statusLog(statusValue) | ||
let statusParameter = coreConnector.core.getNodeStatus(statusValue, node.showStatusActivities) | ||
node.status({fill: statusParameter.fill, shape: statusParameter.shape, text: statusParameter.status}) | ||
} | ||
|
||
node.on('input', function (msg) { | ||
coreConnector.internalDebugLog('connector change request input') | ||
|
||
if (node.connector && msg.payload.endpoint && msg.payload.endpoint.includes('opc.tcp:')) { | ||
coreConnector.internalDebugLog('connector change possible') | ||
coreConnector.internalDebugLog(msg.payload) | ||
node.connector.restartWithNewSettings(msg.payload, () => { | ||
coreConnector.internalDebugLog('connector change injected') | ||
node.send(msg) | ||
}) | ||
} else { | ||
coreConnector.internalDebugLog('Connector Change Not Possible - Wrong Endpoint') | ||
} | ||
}) | ||
|
||
coreConnector.core.registerToConnector(node) | ||
|
||
node.on('close', function (done) { | ||
node.connector.deregisterForOPCUA(node, done) | ||
}) | ||
} | ||
|
||
RED.nodes.registerType('OPCUA-IIoT-Flex-Connector', OPCUAIIoTFlexConnector) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters