Skip to content

Commit

Permalink
fix on close subscription node
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Fantin committed Jul 12, 2024
1 parent c233592 commit 4749793
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
13 changes: 9 additions & 4 deletions opcua-subscription.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
<script type="text/javascript">
RED.nodes.registerType('opcua-subscription',{
RED.nodes.registerType('opcua-subscription', {
category: 'opcuax',
color: '#a6bbcf',
defaults: {
client: {value:"", required: true, type:"opcua-client"},
nodeid: { required: true }
client: { value: "", required: true, type: "opcua-client" },
nodeid: { required: true },
samplinginterval: { value: 100, required: true }
},
inputs: 0,
outputs: 1,
icon: "opcua-logo.png",
label: function() {
label: function () {
return this.defaults.client.name;
}
});
Expand All @@ -24,4 +25,8 @@
<label for="node-input-nodeid"><i class="fa fa-link"></i> NodeId</label>
<input type="text" id="node-input-nodeid" placeholder="ns=*;i=*, ns=*;s=*">
</div>
<div class="form-row">
<label for="node-input-samplinginterval">Sampling Interval (ms)</label>
<input type="number" id="node-input-samplinginterval" placeholder="Interval in milliseconds">
</div>
</script>
8 changes: 3 additions & 5 deletions opcua-subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ module.exports = function (RED) {

let node = this;
node.nodeId = args.nodeid;
node.samplinginterval = args.samplinginterval;
node.on('close', onNodeClosed);

let monitoredItem = new opcua.ClientMonitoredItem();

core.eventEmitter.on('subscription_created', onSubscriptionCreated);
Expand All @@ -32,10 +34,6 @@ module.exports = function (RED) {
monitoredItem = null;
}

const existingClient = core.opcClients[opcuaclientnode.connectionId];

if (!existingClient.session) return;
await core.closeSubscription(existingClient.session);
done();
}

Expand All @@ -46,7 +44,7 @@ module.exports = function (RED) {
};

const parameters = {
samplingInterval: 100,
samplingInterval: node.samplinginterval,
discardOldest: true,
queueSize: 10
};
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-opcua-x",
"version": "0.5.1",
"version": "0.6.0",
"license": "MIT",
"author": {
"name": "Teo230",
Expand Down

0 comments on commit 4749793

Please sign in to comment.