@things-factory/integration-opc 6.1.120 → 6.1.123

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.
@@ -2,9 +2,12 @@
2
2
 
3
3
  OPC-UA サーバーコネクタを使用すると、OPC-UA サーバーインスタンスを作成し、管理することができます。
4
4
 
5
+ ## エンドポイント
6
+
7
+ OPC-UA サーバーがリッスンするポート番号です(endpoint)。
8
+
5
9
  ## パラメータ
6
10
 
7
- - **ポート:** OPC-UA サーバーがリッスンするポート番号です。
8
11
  - **製品名:** OPC-UA サーバーに関連する製品の名前です。
9
12
  - **ビルド番号:** OPC-UA サーバーのビルド番号です。
10
13
  - **ビルド日付:** OPC-UA サーバーのビルド日付です。
@@ -2,9 +2,12 @@
2
2
 
3
3
  OPC-UA 서버 커넥터를 사용하면 OPC-UA 서버 인스턴스를 생성하고 관리할 수 있습니다.
4
4
 
5
+ ## Endpoint
6
+
7
+ OPC-UA 서버가 수신 대기할 포트 번호입니다.
8
+
5
9
  ## 매개변수
6
10
 
7
- - **포트:** OPC-UA 서버가 수신 대기할 포트 번호입니다.
8
11
  - **제품명:** OPC-UA 서버와 관련된 제품의 이름입니다.
9
12
  - **빌드 번호:** OPC-UA 서버의 빌드 번호입니다.
10
13
  - **빌드 날짜:** OPC-UA 서버의 빌드 날짜입니다.
@@ -2,9 +2,12 @@
2
2
 
3
3
  The OPC-UA Server Connector allows you to create and manage an OPC-UA server instance.
4
4
 
5
+ ## Endpoint
6
+
7
+ The port number on which the OPC-UA server will listen.
8
+
5
9
  ## Parameters
6
10
 
7
- - **Port:** The port number on which the OPC-UA server will listen.
8
11
  - **Product Name:** The name of the product associated with the OPC-UA server.
9
12
  - **Build Number:** The build number of the OPC-UA server.
10
13
  - **Build Date:** The build date of the OPC-UA server.
@@ -2,9 +2,12 @@
2
2
 
3
3
  Pemacu Pelayan OPC-UA membolehkan anda untuk membuat dan menguruskan instan Pelayan OPC-UA.
4
4
 
5
+ ## Endpoin
6
+
7
+ Nombor port di mana pelayan OPC-UA akan mendengar.
8
+
5
9
  ## Parameter
6
10
 
7
- - **Port:** Nombor port di mana pelayan OPC-UA akan mendengar.
8
11
  - **Nama Produk:** Nama produk yang berkaitan dengan pelayan OPC-UA.
9
12
  - **Nombor Binaan:** Nombor binaan pelayan OPC-UA.
10
13
  - **Tarikh Binaan:** Tarikh binaan pelayan OPC-UA.
@@ -2,9 +2,12 @@
2
2
 
3
3
  OPC-UA 服务器连接器允许您创建和管理 OPC-UA 服务器实例。
4
4
 
5
+ ## 终端点
6
+
7
+ OPC-UA 服务器将侦听的端口号。
8
+
5
9
  ## 参数
6
10
 
7
- - **端口:** OPC-UA 服务器将侦听的端口号。
8
11
  - **产品名称:** 与 OPC-UA 服务器相关的产品名称。
9
12
  - **构建编号:** OPC-UA 服务器的构建编号。
10
13
  - **构建日期:** OPC-UA 服务器的构建日期。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/integration-opc",
3
- "version": "6.1.120",
3
+ "version": "6.1.123",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "client/index.js",
6
6
  "things-factory": true,
@@ -23,8 +23,8 @@
23
23
  "clean": "npm run clean:server"
24
24
  },
25
25
  "dependencies": {
26
- "@things-factory/integration-base": "^6.1.119",
26
+ "@things-factory/integration-base": "^6.1.123",
27
27
  "node-opcua": "^2.110.0"
28
28
  },
29
- "gitHead": "d9026fbb86bb0e66883bc628653aba7d0931babe"
29
+ "gitHead": "b1440f932f519e74aca05dabf2dd7f6690fcb3cf"
30
30
  }
@@ -30,7 +30,7 @@ export class OPCUAServerConnector implements Connector {
30
30
  })
31
31
 
32
32
  await server.initialize()
33
- ConnectionManager.logger.log('initialized')
33
+ ConnectionManager.logger.info('initialized')
34
34
 
35
35
  const addressSpace = server.engine.addressSpace
36
36
  const namespace = addressSpace.getOwnNamespace()
@@ -98,10 +98,10 @@ export class OPCUAServerConnector implements Connector {
98
98
  })
99
99
 
100
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)
101
+ ConnectionManager.logger.info('Server is now listening ... ( press CTRL+C to stop)')
102
+ ConnectionManager.logger.info('port ', server.endpoints[0].port)
103
103
  const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl
104
- ConnectionManager.logger.log(' the primary server endpoint url is ', endpointUrl)
104
+ ConnectionManager.logger.info(' the primary server endpoint url is ', endpointUrl)
105
105
  })
106
106
 
107
107
  ConnectionManager.addConnectionInstance(config, server)
@@ -6,8 +6,10 @@ import {
6
6
  StatusCodes,
7
7
  TimestampsToReturn,
8
8
  DataValue,
9
+ DataType,
9
10
  StatusCode,
10
- ClientMonitoredItem
11
+ ClientMonitoredItem,
12
+ Variant
11
13
  } from 'node-opcua'
12
14
 
13
15
  import { Connection, ConnectionManager, Connector } from '@things-factory/integration-base'
@@ -45,7 +47,7 @@ export class OPCUAConnector implements Connector {
45
47
  }
46
48
  })
47
49
 
48
- client.on('backoff', () => ConnectionManager.logger.log('retrying connection'))
50
+ client.on('backoff', () => ConnectionManager.logger.info('retrying connection'))
49
51
 
50
52
  await client.connect(endpoint)
51
53
 
@@ -53,7 +55,7 @@ export class OPCUAConnector implements Connector {
53
55
 
54
56
  const browseResult: BrowseResult = (await session.browse('RootFolder')) as BrowseResult
55
57
 
56
- ConnectionManager.logger.log(
58
+ ConnectionManager.logger.info(
57
59
  browseResult.references.map((r: ReferenceDescription) => r.browseName.toString()).join('\n')
58
60
  )
59
61
 
@@ -68,34 +70,37 @@ export class OPCUAConnector implements Connector {
68
70
 
69
71
  subscription
70
72
  .on('started', () =>
71
- ConnectionManager.logger.log('subscription started - subscriptionId=', subscription.subscriptionId)
73
+ ConnectionManager.logger.info('subscription started - subscriptionId=', subscription.subscriptionId)
72
74
  )
73
- .on('keepalive', () => ConnectionManager.logger.log('keepalive'))
74
- .on('terminated', () => ConnectionManager.logger.log('subscription terminated'))
75
+ .on('keepalive', () => ConnectionManager.logger.info('keepalive'))
76
+ .on('terminated', () => ConnectionManager.logger.info('subscription terminated'))
75
77
 
76
78
  try {
77
79
  ConnectionManager.addConnectionInstance(config, {
78
80
  read: async function (node, { logger }): Promise<DataValue> {
79
81
  const dataValue = await session.read({ nodeId: node, attributeId: AttributeIds.Value })
80
82
  if (dataValue.statusCode !== StatusCodes.Good) {
81
- logger.log('Could not read ', node)
83
+ logger.info('Could not read ', node)
82
84
  }
83
- logger.log(` dataValue = ${dataValue.value.toString()}`)
85
+ logger.info(` dataValue = ${dataValue.value.toString()}`)
84
86
 
85
87
  return dataValue
86
88
  },
87
- write: async function (node, value, { logger }): Promise<StatusCode> {
89
+ write: async function (node, dataValue, dataType, { logger }): Promise<StatusCode> {
90
+ const resultVariant = new Variant({
91
+ dataType,
92
+ value: dataValue
93
+ })
94
+
88
95
  const statusCode = await session.write({
89
96
  nodeId: node,
90
97
  attributeId: AttributeIds.Value,
91
98
  value: {
92
- statusCode: StatusCodes.Good,
93
- sourceTimestamp: new Date(),
94
- value
99
+ value: resultVariant
95
100
  }
96
101
  })
97
102
 
98
- logger.log('statusCode = ', statusCode.toString())
103
+ logger.info('statusCode = ', statusCode.name)
99
104
  return statusCode
100
105
  },
101
106
  startMonitor: async function (
@@ -123,6 +128,7 @@ export class OPCUAConnector implements Connector {
123
128
  },
124
129
  stopMonitor: async function (monitoredItem, { logger }): Promise<void> {
125
130
  await monitoredItem.terminate()
131
+ return monitoredItem
126
132
  },
127
133
  close: async function (): Promise<void> {
128
134
  await subscription?.terminate()
@@ -1,4 +1,5 @@
1
1
  import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'
2
+ import { DataValue } from 'node-opcua'
2
3
 
3
4
  async function OPCUARead(step, { logger, domain }) {
4
5
  var {
@@ -16,8 +17,14 @@ async function OPCUARead(step, { logger, domain }) {
16
17
  }
17
18
 
18
19
  var { read } = client
19
- var content = await read(node, { logger })
20
- return content
20
+ var content: DataValue = await read(node, { logger })
21
+
22
+ return {
23
+ data: {
24
+ dataType: content?.value.dataType,
25
+ value: content?.value.value
26
+ }
27
+ }
21
28
  }
22
29
 
23
30
  OPCUARead.parameterSpec = [
@@ -13,11 +13,11 @@ async function OPCUAStartMonitor(step, { logger, domain, data }) {
13
13
  }
14
14
 
15
15
  const callback = (dataValue: DataValue) => {
16
- logger.log('monitored value: %s', dataValue)
16
+ logger.log('monitored value: %s', dataValue?.value.value)
17
17
  }
18
18
 
19
19
  var { startMonitor } = client
20
- return await startMonitor(
20
+ var monitoredItem = await startMonitor(
21
21
  node,
22
22
  callback,
23
23
  {
@@ -27,6 +27,8 @@ async function OPCUAStartMonitor(step, { logger, domain, data }) {
27
27
  },
28
28
  { logger }
29
29
  )
30
+
31
+ return { data: monitoredItem }
30
32
  }
31
33
 
32
34
  OPCUAStartMonitor.parameterSpec = [
@@ -1,6 +1,8 @@
1
1
  import { access } from '@things-factory/utils'
2
2
  import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'
3
3
 
4
+ import { ClientMonitoredItem } from 'node-opcua'
5
+
4
6
  async function OPCUAStopMonitor(step, { logger, domain, data }) {
5
7
  var {
6
8
  connection,
@@ -15,7 +17,11 @@ async function OPCUAStopMonitor(step, { logger, domain, data }) {
15
17
  const item = access(monitorItem, data)
16
18
 
17
19
  var { stopMonitor } = client
18
- return await stopMonitor(item, { logger })
20
+ var monitoredItem: ClientMonitoredItem = await stopMonitor(item, { logger })
21
+
22
+ return {
23
+ data: monitoredItem.statusCode
24
+ }
19
25
  }
20
26
 
21
27
  OPCUAStopMonitor.parameterSpec = [
@@ -1,10 +1,11 @@
1
1
  import { access } from '@things-factory/utils'
2
2
  import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'
3
+ import { StatusCode, DataType } from 'node-opcua'
3
4
 
4
5
  async function OPCUAWrite(step, { logger, domain, data }) {
5
6
  var {
6
7
  connection,
7
- params: { node, accessor }
8
+ params: { node, accessor, type }
8
9
  } = step
9
10
 
10
11
  var client = ConnectionManager.getConnectionInstanceByName(domain, connection)
@@ -15,9 +16,15 @@ async function OPCUAWrite(step, { logger, domain, data }) {
15
16
  const value = access(accessor, data)
16
17
 
17
18
  var { write } = client
18
- var content = await write(node, value, { logger })
19
+ var content: StatusCode = await write(node, value, type, { logger })
19
20
 
20
- return content
21
+ return {
22
+ data: {
23
+ name: content.name,
24
+ description: content.description,
25
+ result: content.isGood()
26
+ }
27
+ }
21
28
  }
22
29
 
23
30
  OPCUAWrite.parameterSpec = [
@@ -30,6 +37,41 @@ OPCUAWrite.parameterSpec = [
30
37
  type: 'scenario-step-input',
31
38
  name: 'accessor',
32
39
  label: 'accessor'
40
+ },
41
+ {
42
+ type: 'select',
43
+ label: 'type',
44
+ name: 'type',
45
+ property: {
46
+ options: [
47
+ { display: 'Null', value: DataType.Null },
48
+ { display: 'Boolean', value: DataType.Boolean },
49
+ { display: 'SByte', value: DataType.SByte },
50
+ { display: 'Byte', value: DataType.Byte },
51
+ { display: 'Int16', value: DataType.Int16 },
52
+ { display: 'UInt16', value: DataType.UInt16 },
53
+ { display: 'Int32', value: DataType.Int32 },
54
+ { display: 'UInt32', value: DataType.UInt32 },
55
+ { display: 'Int64', value: DataType.Int64 },
56
+ { display: 'UInt64', value: DataType.UInt64 },
57
+ { display: 'Float', value: DataType.Float },
58
+ { display: 'Double', value: DataType.Double },
59
+ { display: 'String', value: DataType.String },
60
+ { display: 'DateTime', value: DataType.DateTime },
61
+ { display: 'Guid', value: DataType.Guid },
62
+ { display: 'ByteString', value: DataType.ByteString },
63
+ { display: 'XmlElement', value: DataType.XmlElement },
64
+ { display: 'NodeId', value: DataType.NodeId },
65
+ { display: 'ExpandedNodeId', value: DataType.ExpandedNodeId },
66
+ { display: 'StatusCode', value: DataType.StatusCode },
67
+ { display: 'QualifiedName', value: DataType.QualifiedName },
68
+ { display: 'LocalizedText', value: DataType.LocalizedText },
69
+ { display: 'ExtensionObject', value: DataType.ExtensionObject },
70
+ { display: 'Variant', value: DataType.Variant },
71
+ { display: 'DataValue', value: DataType.DataValue },
72
+ { display: 'DiagnosticInfo', value: DataType.DiagnosticInfo }
73
+ ]
74
+ }
33
75
  }
34
76
  ]
35
77