node-red-contrib-iiot-opcua
Version:
An Industrial IoT OPC UA toolbox contribution package for Node-RED based on node-opcua.
58 lines (55 loc) • 2.08 kB
JavaScript
/*
The BSD 3-Clause License
Copyright 2022 - DATATRONiQ GmbH (https://datatroniq.com)
Copyright (c) 2018-2022 Klaus Landsdorf (http://node-red.plus/)
All rights reserved.
node-red-contrib-iiot-opcua
*/
;
Object.defineProperty(exports, "__esModule", { value: true });
const opcua_iiot_core_connector_1 = require("./core/opcua-iiot-core-connector");
const opcua_iiot_core_1 = require("./core/opcua-iiot-core");
var internalDebugLog = opcua_iiot_core_connector_1.logger.internalDebugLog;
/**
* Address space object Node-RED node.
*
* @param RED
*/
module.exports = (RED) => {
// SOURCE-MAP-REQUIRED
function OPCUAIIoTCMD(config) {
RED.nodes.createNode(this, config);
this.commandtype = config.commandtype;
this.nodeId = config.nodeId;
this.name = config.name;
let self = this;
this.on('input', (msg) => {
let returnPayload = {};
returnPayload.nodetype = 'inject';
returnPayload.injectType = 'CMD';
returnPayload.commandType = self.commandtype;
if (msg.payload.addressSpaceItems && msg.payload.addressSpaceItems.length > 0) {
let addressSpaceItem;
for (addressSpaceItem of msg.payload.addressSpaceItems) {
returnPayload.nodeId = addressSpaceItem.nodeId;
}
if (returnPayload.nodeId) {
this.send(Object.assign(Object.assign({}, msg), { payload: returnPayload }));
}
}
else {
if (self.nodeId) {
returnPayload.nodeId = self.nodeId;
}
this.send(Object.assign(Object.assign({}, msg), { payload: returnPayload }));
}
});
this.on('close', (done) => {
internalDebugLog('Close CMD Node');
(0, opcua_iiot_core_1.resetIiotNode)(self);
done();
});
}
RED.nodes.registerType('OPCUA-IIoT-Server-Command', OPCUAIIoTCMD);
};
//# sourceMappingURL=opcua-iiot-server-cmd.js.map