@things-factory/integration-opc 6.1.120
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +0 -0
- package/dist-server/engine/connector/index.js +5 -0
- package/dist-server/engine/connector/index.js.map +1 -0
- package/dist-server/engine/connector/opc-ua-server.js +124 -0
- package/dist-server/engine/connector/opc-ua-server.js.map +1 -0
- package/dist-server/engine/connector/opc-ua.js +152 -0
- package/dist-server/engine/connector/opc-ua.js.map +1 -0
- package/dist-server/engine/index.js +5 -0
- package/dist-server/engine/index.js.map +1 -0
- package/dist-server/engine/task/index.js +7 -0
- package/dist-server/engine/task/index.js.map +1 -0
- package/dist-server/engine/task/opc-ua-read.js +26 -0
- package/dist-server/engine/task/opc-ua-read.js.map +1 -0
- package/dist-server/engine/task/opc-ua-start-monitor.js +44 -0
- package/dist-server/engine/task/opc-ua-start-monitor.js.map +1 -0
- package/dist-server/engine/task/opc-ua-stop-monitor.js +24 -0
- package/dist-server/engine/task/opc-ua-stop-monitor.js.map +1 -0
- package/dist-server/engine/task/opc-ua-write.js +30 -0
- package/dist-server/engine/task/opc-ua-write.js.map +1 -0
- package/dist-server/index.js +5 -0
- package/dist-server/index.js.map +1 -0
- package/dist-server/tsconfig.tsbuildinfo +1 -0
- package/helps/integration/connector/opc-ua-server.ja.md +22 -0
- package/helps/integration/connector/opc-ua-server.ko.md +22 -0
- package/helps/integration/connector/opc-ua-server.md +22 -0
- package/helps/integration/connector/opc-ua-server.ms.md +22 -0
- package/helps/integration/connector/opc-ua-server.zh.md +22 -0
- package/helps/integration/connector/opc-ua.ja.md +41 -0
- package/helps/integration/connector/opc-ua.ko.md +41 -0
- package/helps/integration/connector/opc-ua.md +41 -0
- package/helps/integration/connector/opc-ua.ms.md +43 -0
- package/helps/integration/connector/opc-ua.zh.md +41 -0
- package/helps/integration/task/opc-ua-read.ja.md +11 -0
- package/helps/integration/task/opc-ua-read.ko.md +11 -0
- package/helps/integration/task/opc-ua-read.md +11 -0
- package/helps/integration/task/opc-ua-read.ms.md +11 -0
- package/helps/integration/task/opc-ua-read.zh.md +11 -0
- package/helps/integration/task/opc-ua-start-monitor.ja.md +14 -0
- package/helps/integration/task/opc-ua-start-monitor.ko.md +14 -0
- package/helps/integration/task/opc-ua-start-monitor.md +14 -0
- package/helps/integration/task/opc-ua-start-monitor.ms.md +14 -0
- package/helps/integration/task/opc-ua-start-monitor.zh.md +14 -0
- package/helps/integration/task/opc-ua-stop-monitor.ja.md +12 -0
- package/helps/integration/task/opc-ua-stop-monitor.ko.md +12 -0
- package/helps/integration/task/opc-ua-stop-monitor.md +12 -0
- package/helps/integration/task/opc-ua-stop-monitor.ms.md +12 -0
- package/helps/integration/task/opc-ua-stop-monitor.zh.md +12 -0
- package/helps/integration/task/opc-ua-write.ja.md +13 -0
- package/helps/integration/task/opc-ua-write.ko.md +13 -0
- package/helps/integration/task/opc-ua-write.md +13 -0
- package/helps/integration/task/opc-ua-write.ms.md +13 -0
- package/helps/integration/task/opc-ua-write.zh.md +13 -0
- package/package.json +30 -0
- package/server/engine/connector/index.ts +2 -0
- package/server/engine/connector/opc-ua-server.ts +145 -0
- package/server/engine/connector/opc-ua.ts +206 -0
- package/server/engine/index.ts +2 -0
- package/server/engine/task/index.ts +4 -0
- package/server/engine/task/opc-ua-read.ts +33 -0
- package/server/engine/task/opc-ua-start-monitor.ts +57 -0
- package/server/engine/task/opc-ua-stop-monitor.ts +31 -0
- package/server/engine/task/opc-ua-write.ts +38 -0
- package/server/index.ts +2 -0
- package/things-factory.config.js +1 -0
- package/translations/en.json +19 -0
- package/translations/ja.json +19 -0
- package/translations/ko.json +19 -0
- package/translations/ms.json +19 -0
- package/translations/zh.json +19 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { StatusCodes, OPCUAServer, Variant, DataType } from 'node-opcua'
|
|
2
|
+
import { ConnectionManager, Connector, Connection } from '@things-factory/integration-base'
|
|
3
|
+
|
|
4
|
+
export class OPCUAServerConnector implements Connector {
|
|
5
|
+
async ready(connectionConfigs) {
|
|
6
|
+
await Promise.all(connectionConfigs.map(this.connect))
|
|
7
|
+
|
|
8
|
+
ConnectionManager.logger.info('opc-ua-servers are ready')
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async connect(config) {
|
|
12
|
+
var {
|
|
13
|
+
name: productName,
|
|
14
|
+
endpoint: port, // the port of the listening socket of the server
|
|
15
|
+
params: {
|
|
16
|
+
resourcePath, // this path will be added to the endpoint resource name
|
|
17
|
+
buildNumber,
|
|
18
|
+
buildDate
|
|
19
|
+
}
|
|
20
|
+
} = config
|
|
21
|
+
|
|
22
|
+
const server = new OPCUAServer({
|
|
23
|
+
port,
|
|
24
|
+
resourcePath,
|
|
25
|
+
buildInfo: {
|
|
26
|
+
productName,
|
|
27
|
+
buildNumber,
|
|
28
|
+
buildDate: buildDate ? new Date(buildDate) : new Date()
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
await server.initialize()
|
|
33
|
+
ConnectionManager.logger.log('initialized')
|
|
34
|
+
|
|
35
|
+
const addressSpace = server.engine.addressSpace
|
|
36
|
+
const namespace = addressSpace.getOwnNamespace()
|
|
37
|
+
|
|
38
|
+
// declare a new object
|
|
39
|
+
const device = namespace.addObject({
|
|
40
|
+
organizedBy: addressSpace.rootFolder.objects,
|
|
41
|
+
browseName: 'MyDevice'
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
// add some variables
|
|
45
|
+
// add a variable named MyVariable1 to the newly created folder "MyDevice"
|
|
46
|
+
let variable1 = 1
|
|
47
|
+
|
|
48
|
+
// emulate variable1 changing every 500 ms
|
|
49
|
+
setInterval(() => {
|
|
50
|
+
variable1 += 1
|
|
51
|
+
}, 500)
|
|
52
|
+
|
|
53
|
+
namespace.addVariable({
|
|
54
|
+
componentOf: device,
|
|
55
|
+
browseName: 'MyVariable1',
|
|
56
|
+
dataType: 'Double',
|
|
57
|
+
value: {
|
|
58
|
+
get: () => new Variant({ dataType: DataType.Double, value: variable1 })
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
// add a variable named MyVariable2 to the newly created folder "MyDevice"
|
|
63
|
+
let variable2 = 10.0
|
|
64
|
+
|
|
65
|
+
namespace.addVariable({
|
|
66
|
+
componentOf: device,
|
|
67
|
+
nodeId: 'ns=1;b=1020FFAA', // some opaque NodeId in namespace 4
|
|
68
|
+
browseName: 'MyVariable2',
|
|
69
|
+
dataType: 'Double',
|
|
70
|
+
minimumSamplingInterval: 1234, // we need to specify a minimumSamplingInterval when using a getter
|
|
71
|
+
value: {
|
|
72
|
+
get: () => new Variant({ dataType: DataType.Double, value: variable2 }),
|
|
73
|
+
set: variant => {
|
|
74
|
+
variable2 = parseFloat(variant.value)
|
|
75
|
+
return StatusCodes.Good
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
const os = require('os')
|
|
80
|
+
/**
|
|
81
|
+
* returns the percentage of free memory on the running machine
|
|
82
|
+
* @return {double}
|
|
83
|
+
*/
|
|
84
|
+
function available_memory() {
|
|
85
|
+
// var value = process.memoryUsage().heapUsed / 1000000;
|
|
86
|
+
const percentageMemUsed = (os.freemem() / os.totalmem()) * 100.0
|
|
87
|
+
return percentageMemUsed
|
|
88
|
+
}
|
|
89
|
+
namespace.addVariable({
|
|
90
|
+
componentOf: device,
|
|
91
|
+
|
|
92
|
+
nodeId: 's=free_memory', // a string nodeID
|
|
93
|
+
browseName: 'FreeMemory',
|
|
94
|
+
dataType: 'Double',
|
|
95
|
+
value: {
|
|
96
|
+
get: () => new Variant({ dataType: DataType.Double, value: available_memory() })
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
server.start(function () {
|
|
101
|
+
ConnectionManager.logger.log('Server is now listening ... ( press CTRL+C to stop)')
|
|
102
|
+
ConnectionManager.logger.log('port ', server.endpoints[0].port)
|
|
103
|
+
const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl
|
|
104
|
+
ConnectionManager.logger.log(' the primary server endpoint url is ', endpointUrl)
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
ConnectionManager.addConnectionInstance(config, server)
|
|
108
|
+
|
|
109
|
+
ConnectionManager.logger.info(`opc-ua-server connection(${config.name}:${port}) is connected`)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
async disconnect(connection: Connection) {
|
|
113
|
+
var server = ConnectionManager.removeConnectionInstance(connection)
|
|
114
|
+
server && server._server.close()
|
|
115
|
+
|
|
116
|
+
ConnectionManager.logger.info(`opc-ua-server connection(${connection.name}) is disconnected`)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
get parameterSpec() {
|
|
120
|
+
return [
|
|
121
|
+
{
|
|
122
|
+
type: 'number',
|
|
123
|
+
name: 'port',
|
|
124
|
+
label: 'port'
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
type: 'string',
|
|
128
|
+
name: 'productName',
|
|
129
|
+
label: 'product-name'
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
type: 'string',
|
|
133
|
+
name: 'buildNumber',
|
|
134
|
+
label: 'build-number'
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
type: 'string',
|
|
138
|
+
name: 'buildDate',
|
|
139
|
+
label: 'build-date'
|
|
140
|
+
}
|
|
141
|
+
]
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
ConnectionManager.registerConnector('opc-ua-server', new OPCUAServerConnector())
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import {
|
|
2
|
+
OPCUAClient,
|
|
3
|
+
BrowseResult,
|
|
4
|
+
ReferenceDescription,
|
|
5
|
+
AttributeIds,
|
|
6
|
+
StatusCodes,
|
|
7
|
+
TimestampsToReturn,
|
|
8
|
+
DataValue,
|
|
9
|
+
StatusCode,
|
|
10
|
+
ClientMonitoredItem
|
|
11
|
+
} from 'node-opcua'
|
|
12
|
+
|
|
13
|
+
import { Connection, ConnectionManager, Connector } from '@things-factory/integration-base'
|
|
14
|
+
|
|
15
|
+
export class OPCUAConnector implements Connector {
|
|
16
|
+
async ready(connectionConfigs) {
|
|
17
|
+
await Promise.all(connectionConfigs.map(this.connect))
|
|
18
|
+
|
|
19
|
+
ConnectionManager.logger.info('opc-ua connections are ready')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async connect(config) {
|
|
23
|
+
var {
|
|
24
|
+
name,
|
|
25
|
+
endpoint,
|
|
26
|
+
params: {
|
|
27
|
+
maxRetry = 2,
|
|
28
|
+
initialDelay = 2000,
|
|
29
|
+
maxDelay = 10 * 1000,
|
|
30
|
+
requestedPublishingInterval = 1000,
|
|
31
|
+
requestedLifetimeCount = 100,
|
|
32
|
+
requestedMaxKeepAliveCount = 20,
|
|
33
|
+
maxNotificationsPerPublish = 10,
|
|
34
|
+
publishingEnabled = true,
|
|
35
|
+
priority = 10
|
|
36
|
+
}
|
|
37
|
+
} = config
|
|
38
|
+
|
|
39
|
+
const client = OPCUAClient.create({
|
|
40
|
+
endpoint_must_exist: false,
|
|
41
|
+
connectionStrategy: {
|
|
42
|
+
maxRetry,
|
|
43
|
+
initialDelay,
|
|
44
|
+
maxDelay
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
client.on('backoff', () => ConnectionManager.logger.log('retrying connection'))
|
|
49
|
+
|
|
50
|
+
await client.connect(endpoint)
|
|
51
|
+
|
|
52
|
+
const session = await client.createSession()
|
|
53
|
+
|
|
54
|
+
const browseResult: BrowseResult = (await session.browse('RootFolder')) as BrowseResult
|
|
55
|
+
|
|
56
|
+
ConnectionManager.logger.log(
|
|
57
|
+
browseResult.references.map((r: ReferenceDescription) => r.browseName.toString()).join('\n')
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
const subscription = await session.createSubscription2({
|
|
61
|
+
requestedPublishingInterval,
|
|
62
|
+
requestedLifetimeCount,
|
|
63
|
+
requestedMaxKeepAliveCount,
|
|
64
|
+
maxNotificationsPerPublish,
|
|
65
|
+
publishingEnabled,
|
|
66
|
+
priority
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
subscription
|
|
70
|
+
.on('started', () =>
|
|
71
|
+
ConnectionManager.logger.log('subscription started - subscriptionId=', subscription.subscriptionId)
|
|
72
|
+
)
|
|
73
|
+
.on('keepalive', () => ConnectionManager.logger.log('keepalive'))
|
|
74
|
+
.on('terminated', () => ConnectionManager.logger.log('subscription terminated'))
|
|
75
|
+
|
|
76
|
+
try {
|
|
77
|
+
ConnectionManager.addConnectionInstance(config, {
|
|
78
|
+
read: async function (node, { logger }): Promise<DataValue> {
|
|
79
|
+
const dataValue = await session.read({ nodeId: node, attributeId: AttributeIds.Value })
|
|
80
|
+
if (dataValue.statusCode !== StatusCodes.Good) {
|
|
81
|
+
logger.log('Could not read ', node)
|
|
82
|
+
}
|
|
83
|
+
logger.log(` dataValue = ${dataValue.value.toString()}`)
|
|
84
|
+
|
|
85
|
+
return dataValue
|
|
86
|
+
},
|
|
87
|
+
write: async function (node, value, { logger }): Promise<StatusCode> {
|
|
88
|
+
const statusCode = await session.write({
|
|
89
|
+
nodeId: node,
|
|
90
|
+
attributeId: AttributeIds.Value,
|
|
91
|
+
value: {
|
|
92
|
+
statusCode: StatusCodes.Good,
|
|
93
|
+
sourceTimestamp: new Date(),
|
|
94
|
+
value
|
|
95
|
+
}
|
|
96
|
+
})
|
|
97
|
+
|
|
98
|
+
logger.log('statusCode = ', statusCode.toString())
|
|
99
|
+
return statusCode
|
|
100
|
+
},
|
|
101
|
+
startMonitor: async function (
|
|
102
|
+
node,
|
|
103
|
+
callback: (dataValue: DataValue) => void,
|
|
104
|
+
options: { samplingInterval: number; discardOldest: boolean; queueSize: number },
|
|
105
|
+
{ logger }
|
|
106
|
+
): Promise<ClientMonitoredItem> {
|
|
107
|
+
const { samplingInterval = 100, discardOldest = true, queueSize = 10 } = options || {}
|
|
108
|
+
const monitoredItem = await subscription.monitor(
|
|
109
|
+
{
|
|
110
|
+
nodeId: node,
|
|
111
|
+
attributeId: AttributeIds.Value
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
samplingInterval,
|
|
115
|
+
discardOldest,
|
|
116
|
+
queueSize
|
|
117
|
+
},
|
|
118
|
+
TimestampsToReturn.Both
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
monitoredItem.on('changed', callback)
|
|
122
|
+
return monitoredItem
|
|
123
|
+
},
|
|
124
|
+
stopMonitor: async function (monitoredItem, { logger }): Promise<void> {
|
|
125
|
+
await monitoredItem.terminate()
|
|
126
|
+
},
|
|
127
|
+
close: async function (): Promise<void> {
|
|
128
|
+
await subscription?.terminate()
|
|
129
|
+
await session?.close()
|
|
130
|
+
await client?.disconnect()
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
ConnectionManager.logger.info(`opc-ua connection(${name}:${endpoint}) is connected`)
|
|
135
|
+
} catch (error) {
|
|
136
|
+
ConnectionManager.logger.info(`opc-ua connection(${name}:${endpoint}) failed to connect`)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async disconnect(connection: Connection) {
|
|
141
|
+
var { close } = ConnectionManager.removeConnectionInstance(connection)
|
|
142
|
+
await close()
|
|
143
|
+
|
|
144
|
+
ConnectionManager.logger.info(`opc-ua connection(${connection.name}) is disconnected`)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
get parameterSpec() {
|
|
148
|
+
return [
|
|
149
|
+
{
|
|
150
|
+
type: 'number',
|
|
151
|
+
name: 'maxRetry',
|
|
152
|
+
label: 'max-retry'
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
type: 'number',
|
|
156
|
+
name: 'initialDelay',
|
|
157
|
+
label: 'initial-delay'
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
type: 'number',
|
|
161
|
+
name: 'maxDelay',
|
|
162
|
+
label: 'max-delay'
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
type: 'number',
|
|
166
|
+
name: 'requestedPublishingInterval',
|
|
167
|
+
label: 'requested-publishing-interval'
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
type: 'number',
|
|
171
|
+
name: 'requestedLifetimeCount',
|
|
172
|
+
label: 'requested-lifetime-count'
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
type: 'number',
|
|
176
|
+
name: 'requestedMaxKeepAliveCount',
|
|
177
|
+
label: 'requested-max-keep-alive-count'
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
type: 'number',
|
|
181
|
+
name: 'maxNotificationsPerPublish',
|
|
182
|
+
label: 'max-notifications-per-publish'
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
type: 'boolean',
|
|
186
|
+
name: 'publishingEnabled',
|
|
187
|
+
label: 'publishing-enabled'
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
type: 'number',
|
|
191
|
+
name: 'priority',
|
|
192
|
+
label: 'priority'
|
|
193
|
+
}
|
|
194
|
+
]
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
get taskPrefixes() {
|
|
198
|
+
return ['opc-ua']
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
get help() {
|
|
202
|
+
return 'integration/connector/opc-ua'
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
ConnectionManager.registerConnector('opc-ua', new OPCUAConnector())
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'
|
|
2
|
+
|
|
3
|
+
async function OPCUARead(step, { logger, domain }) {
|
|
4
|
+
var {
|
|
5
|
+
connection,
|
|
6
|
+
params: { node }
|
|
7
|
+
} = step
|
|
8
|
+
|
|
9
|
+
var client = ConnectionManager.getConnectionInstanceByName(domain, connection)
|
|
10
|
+
if (!client) {
|
|
11
|
+
throw new Error(`no connection : ${connection}`)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
if (!node) {
|
|
15
|
+
throw new Error('node parameter should be defined')
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
var { read } = client
|
|
19
|
+
var content = await read(node, { logger })
|
|
20
|
+
return content
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
OPCUARead.parameterSpec = [
|
|
24
|
+
{
|
|
25
|
+
type: 'string',
|
|
26
|
+
name: 'node',
|
|
27
|
+
label: 'node'
|
|
28
|
+
}
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
OPCUARead.help = 'integration/task/opc-ua-read'
|
|
32
|
+
|
|
33
|
+
TaskRegistry.registerTaskHandler('opc-ua-read', OPCUARead)
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'
|
|
2
|
+
import { DataValue } from 'node-opcua'
|
|
3
|
+
|
|
4
|
+
async function OPCUAStartMonitor(step, { logger, domain, data }) {
|
|
5
|
+
var {
|
|
6
|
+
connection,
|
|
7
|
+
params: { node, samplingInterval, discardOldest, queueSize }
|
|
8
|
+
} = step
|
|
9
|
+
|
|
10
|
+
var client = ConnectionManager.getConnectionInstanceByName(domain, connection)
|
|
11
|
+
if (!client) {
|
|
12
|
+
throw new Error(`no connection : ${connection}`)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const callback = (dataValue: DataValue) => {
|
|
16
|
+
logger.log('monitored value: %s', dataValue)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var { startMonitor } = client
|
|
20
|
+
return await startMonitor(
|
|
21
|
+
node,
|
|
22
|
+
callback,
|
|
23
|
+
{
|
|
24
|
+
samplingInterval,
|
|
25
|
+
discardOldest,
|
|
26
|
+
queueSize
|
|
27
|
+
},
|
|
28
|
+
{ logger }
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
OPCUAStartMonitor.parameterSpec = [
|
|
33
|
+
{
|
|
34
|
+
type: 'string',
|
|
35
|
+
name: 'node',
|
|
36
|
+
label: 'node'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
type: 'number',
|
|
40
|
+
name: 'samplingInterval',
|
|
41
|
+
label: 'sampling-interval'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
name: 'discardOldest',
|
|
46
|
+
label: 'discard-oldest'
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
type: 'number',
|
|
50
|
+
name: 'queueSize',
|
|
51
|
+
label: 'queue-size'
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
OPCUAStartMonitor.help = 'integration/task/opc-ua-start-monitor'
|
|
56
|
+
|
|
57
|
+
TaskRegistry.registerTaskHandler('opc-ua-start-monitor', OPCUAStartMonitor)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { access } from '@things-factory/utils'
|
|
2
|
+
import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'
|
|
3
|
+
|
|
4
|
+
async function OPCUAStopMonitor(step, { logger, domain, data }) {
|
|
5
|
+
var {
|
|
6
|
+
connection,
|
|
7
|
+
params: { monitorItem }
|
|
8
|
+
} = step
|
|
9
|
+
|
|
10
|
+
var client = ConnectionManager.getConnectionInstanceByName(domain, connection)
|
|
11
|
+
if (!client) {
|
|
12
|
+
throw new Error(`no connection : ${connection}`)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const item = access(monitorItem, data)
|
|
16
|
+
|
|
17
|
+
var { stopMonitor } = client
|
|
18
|
+
return await stopMonitor(item, { logger })
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
OPCUAStopMonitor.parameterSpec = [
|
|
22
|
+
{
|
|
23
|
+
type: 'scenario-step-input',
|
|
24
|
+
name: 'monitorItem',
|
|
25
|
+
label: 'monitor-item'
|
|
26
|
+
}
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
OPCUAStopMonitor.help = 'integration/task/opc-ua-stop-monitor'
|
|
30
|
+
|
|
31
|
+
TaskRegistry.registerTaskHandler('opc-ua-stop-monitor', OPCUAStopMonitor)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { access } from '@things-factory/utils'
|
|
2
|
+
import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'
|
|
3
|
+
|
|
4
|
+
async function OPCUAWrite(step, { logger, domain, data }) {
|
|
5
|
+
var {
|
|
6
|
+
connection,
|
|
7
|
+
params: { node, accessor }
|
|
8
|
+
} = step
|
|
9
|
+
|
|
10
|
+
var client = ConnectionManager.getConnectionInstanceByName(domain, connection)
|
|
11
|
+
if (!client) {
|
|
12
|
+
throw new Error(`no connection : ${connection}`)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const value = access(accessor, data)
|
|
16
|
+
|
|
17
|
+
var { write } = client
|
|
18
|
+
var content = await write(node, value, { logger })
|
|
19
|
+
|
|
20
|
+
return content
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
OPCUAWrite.parameterSpec = [
|
|
24
|
+
{
|
|
25
|
+
type: 'string',
|
|
26
|
+
name: 'node',
|
|
27
|
+
label: 'node'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
type: 'scenario-step-input',
|
|
31
|
+
name: 'accessor',
|
|
32
|
+
label: 'accessor'
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
OPCUAWrite.help = 'integration/task/opc-ua-write'
|
|
37
|
+
|
|
38
|
+
TaskRegistry.registerTaskHandler('opc-ua-write', OPCUAWrite)
|
package/server/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default {}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"label.max-retry": "max retry",
|
|
3
|
+
"label.initial-delay": "initial delay",
|
|
4
|
+
"label.max-delay": "max delay",
|
|
5
|
+
"label.requested-publishing-interval": "requested publishing interval",
|
|
6
|
+
"label.requested-lifetime-count": "requested lifetime count",
|
|
7
|
+
"label.requested-max-keep-alive-count": "requested max keep alive count",
|
|
8
|
+
"label.max-notifications-per-publish": "max notifications per publish",
|
|
9
|
+
"label.publishing-enabled": "publishing enabled",
|
|
10
|
+
"label.priority": "priority",
|
|
11
|
+
"label.sampling-interval": "sampling interval",
|
|
12
|
+
"label.discard-oldest": "discard oldest",
|
|
13
|
+
"label.queue-size": "queue size",
|
|
14
|
+
"label.node": "node",
|
|
15
|
+
"label.monitor-item": "monitor item",
|
|
16
|
+
"label.product-name": "product name",
|
|
17
|
+
"label.build-number": "build number",
|
|
18
|
+
"label.build-date": "build date"
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"label.max-retry": "max retry",
|
|
3
|
+
"label.initial-delay": "initial delay",
|
|
4
|
+
"label.max-delay": "max delay",
|
|
5
|
+
"label.requested-publishing-interval": "requested publishing interval",
|
|
6
|
+
"label.requested-lifetime-count": "requested lifetime count",
|
|
7
|
+
"label.requested-max-keep-alive-count": "requested max keep alive count",
|
|
8
|
+
"label.max-notifications-per-publish": "max notifications per publish",
|
|
9
|
+
"label.publishing-enabled": "publishing enabled",
|
|
10
|
+
"label.priority": "priority",
|
|
11
|
+
"label.sampling-interval": "sampling interval",
|
|
12
|
+
"label.discard-oldest": "discard oldest",
|
|
13
|
+
"label.queue-size": "queue size",
|
|
14
|
+
"label.node": "node",
|
|
15
|
+
"label.monitor-item": "monitor item",
|
|
16
|
+
"label.product-name": "product name",
|
|
17
|
+
"label.build-number": "build number",
|
|
18
|
+
"label.build-date": "build date"
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"label.max-retry": "max retry",
|
|
3
|
+
"label.initial-delay": "initial delay",
|
|
4
|
+
"label.max-delay": "max delay",
|
|
5
|
+
"label.requested-publishing-interval": "requested publishing interval",
|
|
6
|
+
"label.requested-lifetime-count": "requested lifetime count",
|
|
7
|
+
"label.requested-max-keep-alive-count": "requested max keep alive count",
|
|
8
|
+
"label.max-notifications-per-publish": "max notifications per publish",
|
|
9
|
+
"label.publishing-enabled": "publishing enabled",
|
|
10
|
+
"label.priority": "priority",
|
|
11
|
+
"label.sampling-interval": "sampling interval",
|
|
12
|
+
"label.discard-oldest": "discard oldest",
|
|
13
|
+
"label.queue-size": "queue size",
|
|
14
|
+
"label.node": "node",
|
|
15
|
+
"label.monitor-item": "monitor item",
|
|
16
|
+
"label.product-name": "product name",
|
|
17
|
+
"label.build-number": "build number",
|
|
18
|
+
"label.build-date": "build date"
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"label.max-retry": "max retry",
|
|
3
|
+
"label.initial-delay": "initial delay",
|
|
4
|
+
"label.max-delay": "max delay",
|
|
5
|
+
"label.requested-publishing-interval": "requested publishing interval",
|
|
6
|
+
"label.requested-lifetime-count": "requested lifetime count",
|
|
7
|
+
"label.requested-max-keep-alive-count": "requested max keep alive count",
|
|
8
|
+
"label.max-notifications-per-publish": "max notifications per publish",
|
|
9
|
+
"label.publishing-enabled": "publishing enabled",
|
|
10
|
+
"label.priority": "priority",
|
|
11
|
+
"label.sampling-interval": "sampling interval",
|
|
12
|
+
"label.discard-oldest": "discard oldest",
|
|
13
|
+
"label.queue-size": "queue size",
|
|
14
|
+
"label.node": "node",
|
|
15
|
+
"label.monitor-item": "monitor item",
|
|
16
|
+
"label.product-name": "product name",
|
|
17
|
+
"label.build-number": "build number",
|
|
18
|
+
"label.build-date": "build date"
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"label.max-retry": "max retry",
|
|
3
|
+
"label.initial-delay": "initial delay",
|
|
4
|
+
"label.max-delay": "max delay",
|
|
5
|
+
"label.requested-publishing-interval": "requested publishing interval",
|
|
6
|
+
"label.requested-lifetime-count": "requested lifetime count",
|
|
7
|
+
"label.requested-max-keep-alive-count": "requested max keep alive count",
|
|
8
|
+
"label.max-notifications-per-publish": "max notifications per publish",
|
|
9
|
+
"label.publishing-enabled": "publishing enabled",
|
|
10
|
+
"label.priority": "priority",
|
|
11
|
+
"label.sampling-interval": "sampling interval",
|
|
12
|
+
"label.discard-oldest": "discard oldest",
|
|
13
|
+
"label.queue-size": "queue size",
|
|
14
|
+
"label.node": "node",
|
|
15
|
+
"label.monitor-item": "monitor item",
|
|
16
|
+
"label.product-name": "product name",
|
|
17
|
+
"label.build-number": "build number",
|
|
18
|
+
"label.build-date": "build date"
|
|
19
|
+
}
|