Skip to content

Commit

Permalink
Fixed browsing issue mikakaraila#108
Browse files Browse the repository at this point in the history
  • Loading branch information
mikakaraila committed Apr 17, 2019
1 parent 12e2aac commit 3d84712
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 69 deletions.
64 changes: 1 addition & 63 deletions examples/Browser_contrib_ui_flow.json
Original file line number Diff line number Diff line change
@@ -1,63 +1 @@
[
{
"id": "4f4fb6ea.24c528",
"type": "ui_tab",
"z": "81ced71a.e3a748",
"name": "Home",
"icon": "dashboard",
"order": "1"
},
{
"id": "fba2b2fa.7ca55",
"type": "OpcUa-Endpoint",
"z": "81ced71a.e3a748",
"endpoint": "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer",
"login": false
},
{
"id": "96a00705.6bc878",
"type": "OpcUa-Browser",
"z": "81ced71a.e3a748",
"endpoint": "fba2b2fa.7ca55",
"item": "",
"datatype": "",
"topic": "ns=4;i=1241",
"items": [],
"x": 250,
"y": 140,
"wires": [
[
"6c3938e3.35a4d8"
]
]
},
{
"id": "6c3938e3.35a4d8",
"type": "ui_template",
"z": "81ced71a.e3a748",
"tab": "4f4fb6ea.24c528",
"name": "",
"group": "OPC UA",
"order": 1,
"format": "<div layout=\"row\" layout-align=\"space-between\">\n <select ng-model=\"item\" ng-options=\"items.item.displayName.text for items in msg.payload\">\n <option value=\"\">-- Objects Root --</option>\n </select>\n <button ng-click=\"send({payload: {actiontype: 'browse', root: item}})\">\n Browse\n </button>\n</div>\n<div layout=\"row\" layout-align=\"space-between\">\n <ul>\n <li ng-repeat=\"items in msg.payload\">\n {{items.item.displayName.text}}: {{items.item.nodeId}}\n </li>\n </ul>\n</div>\n",
"storeOutMessages": false,
"fwdInMessages": false,
"x": 240,
"y": 60,
"wires": [
[
"96a00705.6bc878",
"8913e6ff.e9c3f8"
]
]
},
{
"id": "8913e6ff.e9c3f8",
"type": "ui_toast",
"z": "81ced71a.e3a748",
"name": "",
"x": 450,
"y": 60,
"wires": []
}
]
[{"id":"a24729d8.6e3338","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"a5c3b771.b035f","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false},{"id":"57e89fdc.43d9e","type":"ui_group","z":"","name":"Default","tab":"a5c3b771.b035f","disp":true,"width":"6","collapse":false},{"id":"30bfcadd.1595b6","type":"OpcUa-Endpoint","z":"","endpoint":"opc.tcp://TREL16087112.vstage.co:53530/OPCUA/SimulationServer","secpol":"None","secmode":"NONE","login":false},{"id":"9a453441.d77cc","type":"ui_base","theme":{"name":"theme-light","lightTheme":{"default":"#0094CE","baseColor":"#0094CE","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":true,"reset":false},"darkTheme":{"default":"#097479","baseColor":"#097479","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif","edited":false},"customTheme":{"name":"Untitled Theme 1","default":"#4B7930","baseColor":"#4B7930","baseFont":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"},"themeState":{"base-color":{"default":"#0094CE","value":"#0094CE","edited":false},"page-titlebar-backgroundColor":{"value":"#0094CE","edited":false},"page-backgroundColor":{"value":"#fafafa","edited":false},"page-sidebar-backgroundColor":{"value":"#ffffff","edited":false},"group-textColor":{"value":"#1bbfff","edited":false},"group-borderColor":{"value":"#ffffff","edited":false},"group-backgroundColor":{"value":"#ffffff","edited":false},"widget-textColor":{"value":"#111111","edited":false},"widget-backgroundColor":{"value":"#0094ce","edited":false},"widget-borderColor":{"value":"#ffffff","edited":false},"base-font":{"value":"-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif"}},"angularTheme":{"primary":"indigo","accents":"blue","warn":"red","background":"grey"}},"site":{"name":"Node-RED Dashboard","hideToolbar":"false","allowSwipe":"false","lockMenu":"false","allowTempTheme":"true","dateFormat":"DD/MM/YYYY","sizes":{"sx":48,"sy":48,"gx":6,"gy":6,"cx":6,"cy":6,"px":0,"py":0}}},{"id":"715ed404.79906c","type":"ui_template","z":"a24729d8.6e3338","group":"57e89fdc.43d9e","name":"Browse","order":0,"width":"6","height":"11","format":"<div layout=\"row\" layout-align=\"space-between\">\n <select ng-model=\"item\" ng-options=\"items.item.displayName.text for items in msg.payload\">\n <option value=\"\">-- Objects Root --</option>\n </select>\n <button ng-click=\"send({payload: {actiontype: 'browse', root: item}})\">\n Browse\n </button>\n</div>\n<div layout=\"row\" layout-align=\"space-between\">\n <ul>\n <li ng-repeat=\"items in msg.payload\">\n {{items.item.displayName.text}}: {{items.item.nodeId}}\n </li>\n </ul>\n</div>\n","storeOutMessages":true,"fwdInMessages":false,"templateScope":"local","x":250.49998474121094,"y":81.80000305175781,"wires":[["3da8dc2e.9c9f3c","1a39131f.0bb62d"]]},{"id":"3da8dc2e.9c9f3c","type":"ui_toast","z":"a24729d8.6e3338","position":"top right","displayTime":"2","highlight":"","outputs":0,"ok":"OK","cancel":"","topic":"Browsing...","name":"Action","x":471.49998474121094,"y":82.59999084472656,"wires":[]},{"id":"1a39131f.0bb62d","type":"OpcUa-Browser","z":"a24729d8.6e3338","endpoint":"30bfcadd.1595b6","item":"","datatype":"","topic":"ns=0;s=85/0:Simulation","items":[],"x":250.9000244140625,"y":187.40000915527344,"wires":[["715ed404.79906c"]]}]
15 changes: 10 additions & 5 deletions opcua/103-opcuabrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function (RED) {

var node = this;

var browseTopic = "ns=0;i=85";
var browseTopic = "ns=0;i=85"; // Default root, server Objects

var opcuaEndpoint = RED.nodes.getNode(config.endpoint);

Expand All @@ -53,8 +53,12 @@ module.exports = function (RED) {
});

node.add_item = function (item) {
console.log(item);
if (item) {
node.items.add({
if (!node.items) {
node.items = new Array();
}
node.items.push({
'item': item
});
}
Expand Down Expand Up @@ -96,7 +100,8 @@ module.exports = function (RED) {
var nodes = browse_result.references;
if (nodes instanceof Array) {
nodes.forEach(function (reference) {
// TODO Fix later node.add_item(reference);
// TODO Fix later
node.add_item(reference);
});
}
}
Expand Down Expand Up @@ -155,7 +160,7 @@ module.exports = function (RED) {
browseTopic = null;

node.warn("input browser");

if (msg.payload.hasOwnProperty('actiontype')) {

switch (msg.payload.actiontype) {
Expand All @@ -182,7 +187,7 @@ module.exports = function (RED) {
}
}

node.items = []; // clear items - TODO: may it becomes usable in Edit window of the node
node.items = []; // new Array(); // clear items - TODO: may it becomes usable in Edit window of the node

if (!browseTopic) {
browseTopic = browse_to_root();
Expand Down
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-contrib-opcua",
"version": "0.2.44",
"version": "0.2.45",
"description": "A Node-RED node to communicate via OPC UA based on node-opcua library.",
"repository": {
"type": "git",
Expand Down

0 comments on commit 3d84712

Please sign in to comment.