opcua-webapi-ts 1.0.19
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/README.md +34 -0
- package/dist/cjs/client/UaClientConfigure.d.ts +9 -0
- package/dist/cjs/client/UaClientConfigure.js +24 -0
- package/dist/cjs/client/UaWebClient.d.ts +38 -0
- package/dist/cjs/client/UaWebClient.js +590 -0
- package/dist/cjs/client/index.d.ts +3 -0
- package/dist/cjs/client/index.js +19 -0
- package/dist/cjs/client/utils/UaDataTypeDictionary.d.ts +15 -0
- package/dist/cjs/client/utils/UaDataTypeDictionary.js +149 -0
- package/dist/cjs/client/utils/UaNodeReader.d.ts +83 -0
- package/dist/cjs/client/utils/UaNodeReader.js +714 -0
- package/dist/cjs/client/utils/UaObjectTypeDictionary.d.ts +12 -0
- package/dist/cjs/client/utils/UaObjectTypeDictionary.js +80 -0
- package/dist/cjs/client/utils/UaReferenceTypeDictionary.d.ts +12 -0
- package/dist/cjs/client/utils/UaReferenceTypeDictionary.js +80 -0
- package/dist/cjs/client/utils/index.d.ts +4 -0
- package/dist/cjs/client/utils/index.js +20 -0
- package/dist/cjs/common/index.d.ts +4 -0
- package/dist/cjs/common/index.js +20 -0
- package/dist/cjs/common/mapper/UaPayloadMapper.d.ts +18 -0
- package/dist/cjs/common/mapper/UaPayloadMapper.js +481 -0
- package/dist/cjs/common/mapper/index.d.ts +1 -0
- package/dist/cjs/common/mapper/index.js +17 -0
- package/dist/cjs/common/nodes/Identifiers.d.ts +2458 -0
- package/dist/cjs/common/nodes/Identifiers.js +2470 -0
- package/dist/cjs/common/nodes/UaAttributes.d.ts +18 -0
- package/dist/cjs/common/nodes/UaAttributes.js +2 -0
- package/dist/cjs/common/nodes/UaDataType.d.ts +15 -0
- package/dist/cjs/common/nodes/UaDataType.js +93 -0
- package/dist/cjs/common/nodes/UaMethod.d.ts +16 -0
- package/dist/cjs/common/nodes/UaMethod.js +77 -0
- package/dist/cjs/common/nodes/UaNode.d.ts +38 -0
- package/dist/cjs/common/nodes/UaNode.js +94 -0
- package/dist/cjs/common/nodes/UaObject.d.ts +16 -0
- package/dist/cjs/common/nodes/UaObject.js +69 -0
- package/dist/cjs/common/nodes/UaObjectType.d.ts +12 -0
- package/dist/cjs/common/nodes/UaObjectType.js +62 -0
- package/dist/cjs/common/nodes/UaReferenceType.d.ts +12 -0
- package/dist/cjs/common/nodes/UaReferenceType.js +33 -0
- package/dist/cjs/common/nodes/UaVariable.d.ts +25 -0
- package/dist/cjs/common/nodes/UaVariable.js +76 -0
- package/dist/cjs/common/nodes/UaVariableType.d.ts +14 -0
- package/dist/cjs/common/nodes/UaVariableType.js +50 -0
- package/dist/cjs/common/nodes/index.d.ts +10 -0
- package/dist/cjs/common/nodes/index.js +26 -0
- package/dist/cjs/common/structure/UaArgument.d.ts +19 -0
- package/dist/cjs/common/structure/UaArgument.js +65 -0
- package/dist/cjs/common/structure/UaContentFilter.d.ts +13 -0
- package/dist/cjs/common/structure/UaContentFilter.js +48 -0
- package/dist/cjs/common/structure/UaContentFilterElement.d.ts +12 -0
- package/dist/cjs/common/structure/UaContentFilterElement.js +43 -0
- package/dist/cjs/common/structure/UaEUInformation.d.ts +18 -0
- package/dist/cjs/common/structure/UaEUInformation.js +56 -0
- package/dist/cjs/common/structure/UaElementOperand.d.ts +12 -0
- package/dist/cjs/common/structure/UaElementOperand.js +36 -0
- package/dist/cjs/common/structure/UaEnumValueType.d.ts +16 -0
- package/dist/cjs/common/structure/UaEnumValueType.js +48 -0
- package/dist/cjs/common/structure/UaEventFilter.d.ts +14 -0
- package/dist/cjs/common/structure/UaEventFilter.js +49 -0
- package/dist/cjs/common/structure/UaHistoryData.d.ts +12 -0
- package/dist/cjs/common/structure/UaHistoryData.js +43 -0
- package/dist/cjs/common/structure/UaHistoryEvent.d.ts +12 -0
- package/dist/cjs/common/structure/UaHistoryEvent.js +59 -0
- package/dist/cjs/common/structure/UaLiteralOperand.d.ts +12 -0
- package/dist/cjs/common/structure/UaLiteralOperand.js +43 -0
- package/dist/cjs/common/structure/UaRange.d.ts +14 -0
- package/dist/cjs/common/structure/UaRange.js +44 -0
- package/dist/cjs/common/structure/UaReadAtTimeDetails.d.ts +14 -0
- package/dist/cjs/common/structure/UaReadAtTimeDetails.js +41 -0
- package/dist/cjs/common/structure/UaReadEventDetails.d.ts +19 -0
- package/dist/cjs/common/structure/UaReadEventDetails.js +57 -0
- package/dist/cjs/common/structure/UaReadRawModifiedDetails.d.ts +20 -0
- package/dist/cjs/common/structure/UaReadRawModifiedDetails.js +58 -0
- package/dist/cjs/common/structure/UaSimpleAttributeOperand.d.ts +14 -0
- package/dist/cjs/common/structure/UaSimpleAttributeOperand.js +43 -0
- package/dist/cjs/common/structure/index.d.ts +15 -0
- package/dist/cjs/common/structure/index.js +31 -0
- package/dist/cjs/common/types/UaDataValue.d.ts +14 -0
- package/dist/cjs/common/types/UaDataValue.js +28 -0
- package/dist/cjs/common/types/UaError.d.ts +6 -0
- package/dist/cjs/common/types/UaError.js +15 -0
- package/dist/cjs/common/types/UaExpandedNodeId.d.ts +15 -0
- package/dist/cjs/common/types/UaExpandedNodeId.js +51 -0
- package/dist/cjs/common/types/UaExtensionObject.d.ts +9 -0
- package/dist/cjs/common/types/UaExtensionObject.js +19 -0
- package/dist/cjs/common/types/UaHistoryDataResult.d.ts +8 -0
- package/dist/cjs/common/types/UaHistoryDataResult.js +16 -0
- package/dist/cjs/common/types/UaHistoryEventFieldList.d.ts +7 -0
- package/dist/cjs/common/types/UaHistoryEventFieldList.js +23 -0
- package/dist/cjs/common/types/UaHistoryEventResult.d.ts +8 -0
- package/dist/cjs/common/types/UaHistoryEventResult.js +16 -0
- package/dist/cjs/common/types/UaLink.d.ts +12 -0
- package/dist/cjs/common/types/UaLink.js +24 -0
- package/dist/cjs/common/types/UaLocalizedText.d.ts +9 -0
- package/dist/cjs/common/types/UaLocalizedText.js +20 -0
- package/dist/cjs/common/types/UaNodeId.d.ts +23 -0
- package/dist/cjs/common/types/UaNodeId.js +154 -0
- package/dist/cjs/common/types/UaQuery.d.ts +11 -0
- package/dist/cjs/common/types/UaQuery.js +82 -0
- package/dist/cjs/common/types/UaQueryFilter.d.ts +27 -0
- package/dist/cjs/common/types/UaQueryFilter.js +74 -0
- package/dist/cjs/common/types/UaRequestPatameters.d.ts +11 -0
- package/dist/cjs/common/types/UaRequestPatameters.js +29 -0
- package/dist/cjs/common/types/UaServiceTypes.d.ts +18 -0
- package/dist/cjs/common/types/UaServiceTypes.js +2 -0
- package/dist/cjs/common/types/UaStatusCode.d.ts +24 -0
- package/dist/cjs/common/types/UaStatusCode.js +76 -0
- package/dist/cjs/common/types/UaTypes.d.ts +12 -0
- package/dist/cjs/common/types/UaTypes.js +2 -0
- package/dist/cjs/common/types/UaVariant.d.ts +89 -0
- package/dist/cjs/common/types/UaVariant.js +384 -0
- package/dist/cjs/common/types/index.d.ts +17 -0
- package/dist/cjs/common/types/index.js +33 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +18 -0
- package/dist/client/UaClientConfigure.d.ts +9 -0
- package/dist/client/UaClientConfigure.js +24 -0
- package/dist/client/UaWebClient.d.ts +38 -0
- package/dist/client/UaWebClient.js +590 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.js +19 -0
- package/dist/client/utils/UaDataTypeDictionary.d.ts +15 -0
- package/dist/client/utils/UaDataTypeDictionary.js +149 -0
- package/dist/client/utils/UaNodeReader.d.ts +83 -0
- package/dist/client/utils/UaNodeReader.js +714 -0
- package/dist/client/utils/UaObjectTypeDictionary.d.ts +12 -0
- package/dist/client/utils/UaObjectTypeDictionary.js +80 -0
- package/dist/client/utils/UaReferenceTypeDictionary.d.ts +12 -0
- package/dist/client/utils/UaReferenceTypeDictionary.js +80 -0
- package/dist/client/utils/index.d.ts +4 -0
- package/dist/client/utils/index.js +20 -0
- package/dist/common/index.d.ts +4 -0
- package/dist/common/index.js +20 -0
- package/dist/common/mapper/UaPayloadMapper.d.ts +18 -0
- package/dist/common/mapper/UaPayloadMapper.js +481 -0
- package/dist/common/mapper/index.d.ts +1 -0
- package/dist/common/mapper/index.js +17 -0
- package/dist/common/nodes/Identifiers.d.ts +2458 -0
- package/dist/common/nodes/Identifiers.js +2470 -0
- package/dist/common/nodes/UaAttributes.d.ts +18 -0
- package/dist/common/nodes/UaAttributes.js +2 -0
- package/dist/common/nodes/UaDataType.d.ts +15 -0
- package/dist/common/nodes/UaDataType.js +93 -0
- package/dist/common/nodes/UaMethod.d.ts +16 -0
- package/dist/common/nodes/UaMethod.js +77 -0
- package/dist/common/nodes/UaNode.d.ts +38 -0
- package/dist/common/nodes/UaNode.js +94 -0
- package/dist/common/nodes/UaObject.d.ts +16 -0
- package/dist/common/nodes/UaObject.js +69 -0
- package/dist/common/nodes/UaObjectType.d.ts +12 -0
- package/dist/common/nodes/UaObjectType.js +62 -0
- package/dist/common/nodes/UaReferenceType.d.ts +12 -0
- package/dist/common/nodes/UaReferenceType.js +33 -0
- package/dist/common/nodes/UaVariable.d.ts +25 -0
- package/dist/common/nodes/UaVariable.js +76 -0
- package/dist/common/nodes/UaVariableType.d.ts +14 -0
- package/dist/common/nodes/UaVariableType.js +50 -0
- package/dist/common/nodes/index.d.ts +10 -0
- package/dist/common/nodes/index.js +26 -0
- package/dist/common/structure/UaArgument.d.ts +19 -0
- package/dist/common/structure/UaArgument.js +65 -0
- package/dist/common/structure/UaContentFilter.d.ts +13 -0
- package/dist/common/structure/UaContentFilter.js +48 -0
- package/dist/common/structure/UaContentFilterElement.d.ts +12 -0
- package/dist/common/structure/UaContentFilterElement.js +43 -0
- package/dist/common/structure/UaEUInformation.d.ts +18 -0
- package/dist/common/structure/UaEUInformation.js +56 -0
- package/dist/common/structure/UaElementOperand.d.ts +12 -0
- package/dist/common/structure/UaElementOperand.js +36 -0
- package/dist/common/structure/UaEnumValueType.d.ts +16 -0
- package/dist/common/structure/UaEnumValueType.js +48 -0
- package/dist/common/structure/UaEventFilter.d.ts +14 -0
- package/dist/common/structure/UaEventFilter.js +49 -0
- package/dist/common/structure/UaHistoryData.d.ts +12 -0
- package/dist/common/structure/UaHistoryData.js +43 -0
- package/dist/common/structure/UaHistoryEvent.d.ts +12 -0
- package/dist/common/structure/UaHistoryEvent.js +59 -0
- package/dist/common/structure/UaLiteralOperand.d.ts +12 -0
- package/dist/common/structure/UaLiteralOperand.js +43 -0
- package/dist/common/structure/UaRange.d.ts +14 -0
- package/dist/common/structure/UaRange.js +44 -0
- package/dist/common/structure/UaReadAtTimeDetails.d.ts +14 -0
- package/dist/common/structure/UaReadAtTimeDetails.js +41 -0
- package/dist/common/structure/UaReadEventDetails.d.ts +19 -0
- package/dist/common/structure/UaReadEventDetails.js +57 -0
- package/dist/common/structure/UaReadRawModifiedDetails.d.ts +20 -0
- package/dist/common/structure/UaReadRawModifiedDetails.js +58 -0
- package/dist/common/structure/UaSimpleAttributeOperand.d.ts +14 -0
- package/dist/common/structure/UaSimpleAttributeOperand.js +43 -0
- package/dist/common/structure/index.d.ts +15 -0
- package/dist/common/structure/index.js +31 -0
- package/dist/common/types/UaDataValue.d.ts +14 -0
- package/dist/common/types/UaDataValue.js +28 -0
- package/dist/common/types/UaError.d.ts +6 -0
- package/dist/common/types/UaError.js +15 -0
- package/dist/common/types/UaExpandedNodeId.d.ts +15 -0
- package/dist/common/types/UaExpandedNodeId.js +51 -0
- package/dist/common/types/UaExtensionObject.d.ts +9 -0
- package/dist/common/types/UaExtensionObject.js +19 -0
- package/dist/common/types/UaHistoryDataResult.d.ts +8 -0
- package/dist/common/types/UaHistoryDataResult.js +16 -0
- package/dist/common/types/UaHistoryEventFieldList.d.ts +7 -0
- package/dist/common/types/UaHistoryEventFieldList.js +23 -0
- package/dist/common/types/UaHistoryEventResult.d.ts +8 -0
- package/dist/common/types/UaHistoryEventResult.js +16 -0
- package/dist/common/types/UaLink.d.ts +12 -0
- package/dist/common/types/UaLink.js +24 -0
- package/dist/common/types/UaLocalizedText.d.ts +9 -0
- package/dist/common/types/UaLocalizedText.js +20 -0
- package/dist/common/types/UaNodeId.d.ts +23 -0
- package/dist/common/types/UaNodeId.js +154 -0
- package/dist/common/types/UaQuery.d.ts +11 -0
- package/dist/common/types/UaQuery.js +82 -0
- package/dist/common/types/UaQueryFilter.d.ts +27 -0
- package/dist/common/types/UaQueryFilter.js +74 -0
- package/dist/common/types/UaRequestPatameters.d.ts +11 -0
- package/dist/common/types/UaRequestPatameters.js +29 -0
- package/dist/common/types/UaServiceTypes.d.ts +18 -0
- package/dist/common/types/UaServiceTypes.js +2 -0
- package/dist/common/types/UaStatusCode.d.ts +24 -0
- package/dist/common/types/UaStatusCode.js +76 -0
- package/dist/common/types/UaTypes.d.ts +12 -0
- package/dist/common/types/UaTypes.js +2 -0
- package/dist/common/types/UaVariant.d.ts +89 -0
- package/dist/common/types/UaVariant.js +384 -0
- package/dist/common/types/index.d.ts +17 -0
- package/dist/common/types/index.js +33 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -0
- package/package.json +23 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { DefaultApi, ViewDescription, BrowseDescription, BrowseResult, ReadValueId, WriteValue, StatusCode, CallMethodRequest, CallMethodResult, BrowsePath, BrowsePathResult, ApplicationDescription, BrowseDirection, EndpointDescription, DataValue, HistoryReadValueId, ExtensionObject, HistoryReadResult } from "opcua-webapi";
|
|
2
|
+
import { UaBrowseResult, UaNodeAttributes, UaVariableAttributes, UaNodeId, UaDataValue, UaVariant, UaStatusCode, UaWriteValue, UaHistoryDataResult, UaQuery, UaObjectAttributes, UaMethodArguments, UaApplicationDescriptor } from "../common";
|
|
3
|
+
import { UaClientConfiguration, UaClientParameters } from "..";
|
|
4
|
+
import { UaHistoryEventResult } from "../common";
|
|
5
|
+
export declare class UaWebClient {
|
|
6
|
+
private api;
|
|
7
|
+
private clientConfig;
|
|
8
|
+
private requestHandle;
|
|
9
|
+
protected authenticationToken: string | undefined;
|
|
10
|
+
constructor(clientConfig: UaClientConfiguration);
|
|
11
|
+
getUrl(): string;
|
|
12
|
+
getNativeApi(): DefaultApi;
|
|
13
|
+
find(applicationUris?: Array<string>): Promise<Array<UaApplicationDescriptor>>;
|
|
14
|
+
browseChild(nodeId: UaNodeId, nodeClass?: number, maxReferences?: number): Promise<UaBrowseResult>;
|
|
15
|
+
browseReference(nodeId: UaNodeId, nodeClass?: number, direction?: BrowseDirection, referenceTypeId?: UaNodeId, maxReferences?: number): Promise<UaBrowseResult>;
|
|
16
|
+
browseNextByCP(continuationPoint: string): Promise<UaBrowseResult>;
|
|
17
|
+
readValues(nodeIds: Array<UaNodeId>, timestampsToReturn?: number): Promise<Array<UaDataValue>>;
|
|
18
|
+
writeValues(nodesToWrite: Array<UaWriteValue>): Promise<Array<UaStatusCode>>;
|
|
19
|
+
readNodeAttributes(nodeId: UaNodeId, returnDescription?: boolean): Promise<UaNodeAttributes>;
|
|
20
|
+
readVariableAttributes(nodeIds: Array<UaNodeId>): Promise<Array<UaVariableAttributes>>;
|
|
21
|
+
readMethodArguments(nodeId: UaNodeId): Promise<UaMethodArguments>;
|
|
22
|
+
readObjectAttributes(nodeId: UaNodeId): Promise<UaObjectAttributes>;
|
|
23
|
+
methodCall(objectId: UaNodeId, methodId: UaNodeId, inputArguments: Array<UaVariant>): Promise<Array<UaVariant>>;
|
|
24
|
+
getGeneratedEventType(typeId: UaNodeId): Promise<Array<UaNodeId>>;
|
|
25
|
+
historyReadRawData(nodeId: UaNodeId, startTime: Date, endTime: Date, numValuesPerNode?: number | null, continuationPoint?: string | null, returnBounds?: boolean | null, isReadModified?: boolean | null, timestampsToReturn?: number | null, releaseContinuationPoints?: boolean | null): Promise<UaHistoryDataResult>;
|
|
26
|
+
historyReadAtTime(nodeId: UaNodeId, requiredTimes: Array<Date>, useSimpleBounds?: boolean | null, continuationPoint?: string | null, timestampsToReturn?: number | null, releaseContinuationPoints?: boolean | null): Promise<UaHistoryDataResult>;
|
|
27
|
+
historyReadEvent(nodeId: UaNodeId, startTime: Date, endTime: Date, select: Array<string>, where?: UaQuery | null, numValuesPerNode?: number | null, continuationPoint?: string | null, releaseContinuationPoints?: boolean | null): Promise<UaHistoryEventResult>;
|
|
28
|
+
browse(nodesToBrowse: Array<BrowseDescription>, maxReferencesPerNode?: number, view?: ViewDescription, additionalParameters?: UaClientParameters): Promise<Array<BrowseResult>>;
|
|
29
|
+
browseNext(continuationPoints: Array<string>, releaseContinuationPoints: boolean, additionalParameters?: UaClientParameters): Promise<Array<BrowseResult>>;
|
|
30
|
+
translate(browsePaths: Array<BrowsePath>, additionalParameters?: UaClientParameters): Promise<Array<BrowsePathResult>>;
|
|
31
|
+
read(nodesToRead: Array<ReadValueId>, timestampsToReturn?: number, maxAge?: number, additionalParameters?: UaClientParameters): Promise<Array<DataValue>>;
|
|
32
|
+
write(nodesToWrite: Array<WriteValue>, additionalParameters?: UaClientParameters): Promise<Array<StatusCode>>;
|
|
33
|
+
call(methodsToCall: Array<CallMethodRequest>, additionalParameters?: UaClientParameters): Promise<Array<CallMethodResult>>;
|
|
34
|
+
historyRead(nodesToRead: Array<HistoryReadValueId>, historyReadDetails: ExtensionObject, timestampsToReturn?: number, releaseContinuationPoints?: boolean, additionalParameters?: UaClientParameters): Promise<Array<HistoryReadResult>>;
|
|
35
|
+
findServer(endpointUrl: string, serverUris: Array<string>, localeIds?: Array<string>, additionalParameters?: UaClientParameters): Promise<Array<ApplicationDescription>>;
|
|
36
|
+
getEndpoints(endpointUrl?: string, localeIds?: Array<string>, profileUris?: Array<string>, additionalParameters?: UaClientParameters): Promise<Array<EndpointDescription>>;
|
|
37
|
+
private requestHeader;
|
|
38
|
+
}
|
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UaWebClient = void 0;
|
|
13
|
+
const opcua_webapi_1 = require("opcua-webapi");
|
|
14
|
+
const common_1 = require("../common");
|
|
15
|
+
const common_2 = require("../common");
|
|
16
|
+
class UaWebClient {
|
|
17
|
+
constructor(clientConfig) {
|
|
18
|
+
this.api = new opcua_webapi_1.DefaultApi(clientConfig.apiConfig);
|
|
19
|
+
this.clientConfig = clientConfig;
|
|
20
|
+
this.requestHandle = 1;
|
|
21
|
+
}
|
|
22
|
+
getUrl() {
|
|
23
|
+
return this.clientConfig.apiConfig.basePath;
|
|
24
|
+
}
|
|
25
|
+
getNativeApi() {
|
|
26
|
+
return this.api;
|
|
27
|
+
}
|
|
28
|
+
find(applicationUris) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
let results = yield this.findServer(this.clientConfig.apiConfig.basePath, (applicationUris) ? applicationUris : []);
|
|
31
|
+
let ret = [];
|
|
32
|
+
for (let item of results) {
|
|
33
|
+
ret.push({
|
|
34
|
+
applicationUri: (item.ApplicationUri) ? item.ApplicationUri : "",
|
|
35
|
+
applicationName: common_1.UaPayloadMapper.localizedTextFromWebApi(item.ApplicationName),
|
|
36
|
+
productUri: (item.ProductUri) ? item.ProductUri : "",
|
|
37
|
+
urls: (item.DiscoveryUrls) ? item.DiscoveryUrls : []
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return ret;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
browseChild(nodeId, nodeClass, maxReferences) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
let nodesToBrowse = {
|
|
46
|
+
NodeId: nodeId.toString(),
|
|
47
|
+
BrowseDirection: opcua_webapi_1.BrowseDirection.Forward,
|
|
48
|
+
ReferenceTypeId: opcua_webapi_1.ReferenceTypeIds.HierarchicalReferences,
|
|
49
|
+
IncludeSubtypes: true,
|
|
50
|
+
NodeClassMask: (nodeClass) ? nodeClass : Number(opcua_webapi_1.NodeClass.Object | opcua_webapi_1.NodeClass.Variable | opcua_webapi_1.NodeClass.Method),
|
|
51
|
+
ResultMask: 63
|
|
52
|
+
};
|
|
53
|
+
let results = yield this.browse([nodesToBrowse], maxReferences);
|
|
54
|
+
let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
|
|
55
|
+
if (statusCode.isNotGood())
|
|
56
|
+
throw new common_1.UaError(statusCode);
|
|
57
|
+
return common_1.UaPayloadMapper.browseResultFromWebApi(results[0]);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
browseReference(nodeId, nodeClass, direction, referenceTypeId, maxReferences) {
|
|
61
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
62
|
+
let nodesToBrowse = {
|
|
63
|
+
NodeId: nodeId.toString(),
|
|
64
|
+
BrowseDirection: (direction) ? direction : opcua_webapi_1.BrowseDirection.Forward,
|
|
65
|
+
ReferenceTypeId: (referenceTypeId) ? referenceTypeId.toString() : opcua_webapi_1.ReferenceTypeIds.NonHierarchicalReferences,
|
|
66
|
+
IncludeSubtypes: true,
|
|
67
|
+
NodeClassMask: (nodeClass) ? nodeClass : Number(opcua_webapi_1.NodeClass.Object | opcua_webapi_1.NodeClass.Variable | opcua_webapi_1.NodeClass.Method),
|
|
68
|
+
ResultMask: 63
|
|
69
|
+
};
|
|
70
|
+
let results = yield this.browse([nodesToBrowse], maxReferences);
|
|
71
|
+
let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
|
|
72
|
+
if (statusCode.isNotGood())
|
|
73
|
+
throw new common_1.UaError(statusCode);
|
|
74
|
+
return common_1.UaPayloadMapper.browseResultFromWebApi(results[0]);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
browseNextByCP(continuationPoint) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
let results = yield this.browseNext([continuationPoint], false);
|
|
80
|
+
let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
|
|
81
|
+
if (statusCode.isNotGood())
|
|
82
|
+
throw new common_1.UaError(statusCode);
|
|
83
|
+
return common_1.UaPayloadMapper.browseResultFromWebApi(results[0]);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
readValues(nodeIds, timestampsToReturn) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
if (nodeIds.length == 0)
|
|
89
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNothingToDo));
|
|
90
|
+
let nodesToRead = [];
|
|
91
|
+
for (let item of nodeIds) {
|
|
92
|
+
nodesToRead.push({ NodeId: item.toString(), AttributeId: opcua_webapi_1.Attributes.Value });
|
|
93
|
+
}
|
|
94
|
+
let results = yield this.read(nodesToRead, timestampsToReturn);
|
|
95
|
+
let dataValues = [];
|
|
96
|
+
for (let item of results) {
|
|
97
|
+
dataValues.push(common_1.UaPayloadMapper.dataValueFromWebApi(item));
|
|
98
|
+
}
|
|
99
|
+
return dataValues;
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
writeValues(nodesToWrite) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
if (nodesToWrite.length == 0)
|
|
105
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNothingToDo));
|
|
106
|
+
let writeValues = [];
|
|
107
|
+
for (let item of nodesToWrite) {
|
|
108
|
+
let variant = common_1.UaPayloadMapper.variantToWebApi(item.value);
|
|
109
|
+
writeValues.push({
|
|
110
|
+
NodeId: item.nodeId.toString(),
|
|
111
|
+
Value: {
|
|
112
|
+
UaType: variant.UaType,
|
|
113
|
+
Value: variant.Value
|
|
114
|
+
},
|
|
115
|
+
AttributeId: opcua_webapi_1.Attributes.Value
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
let results = yield this.write(writeValues);
|
|
119
|
+
let statusCodes = [];
|
|
120
|
+
for (let item of results) {
|
|
121
|
+
statusCodes.push(common_1.UaPayloadMapper.statusCodeFromWebApi(item));
|
|
122
|
+
}
|
|
123
|
+
return statusCodes;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
readNodeAttributes(nodeId, returnDescription) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
let nodeIdStr = nodeId.toString();
|
|
129
|
+
let nodesToRead = [
|
|
130
|
+
{ NodeId: nodeIdStr, AttributeId: opcua_webapi_1.Attributes.NodeClass },
|
|
131
|
+
{ NodeId: nodeIdStr, AttributeId: opcua_webapi_1.Attributes.BrowseName },
|
|
132
|
+
{ NodeId: nodeIdStr, AttributeId: opcua_webapi_1.Attributes.DisplayName },
|
|
133
|
+
{ NodeId: nodeIdStr, AttributeId: opcua_webapi_1.Attributes.UserWriteMask }
|
|
134
|
+
];
|
|
135
|
+
if (returnDescription) {
|
|
136
|
+
nodesToRead.push({ NodeId: nodeIdStr, AttributeId: opcua_webapi_1.Attributes.Description });
|
|
137
|
+
}
|
|
138
|
+
let results = yield this.read(nodesToRead);
|
|
139
|
+
let dataValues = [];
|
|
140
|
+
for (let item of results) {
|
|
141
|
+
dataValues.push(common_1.UaPayloadMapper.dataValueFromWebApi(item));
|
|
142
|
+
}
|
|
143
|
+
if (dataValues[0].statusCode.isNotGood())
|
|
144
|
+
throw new common_1.UaError(dataValues[0].statusCode);
|
|
145
|
+
if (dataValues[1].statusCode.isNotGood())
|
|
146
|
+
throw new common_1.UaError(dataValues[1].statusCode);
|
|
147
|
+
if (dataValues[2].statusCode.isNotGood())
|
|
148
|
+
throw new common_1.UaError(dataValues[2].statusCode);
|
|
149
|
+
let nodeClassValue = dataValues[0].value;
|
|
150
|
+
let browseNameValue = dataValues[1].value;
|
|
151
|
+
let displayNameValue = dataValues[2].value;
|
|
152
|
+
if (common_1.UaVariantType.Int32 != nodeClassValue.type ||
|
|
153
|
+
common_1.UaVariantType.QualifiedName != browseNameValue.type ||
|
|
154
|
+
common_1.UaVariantType.LocalizedText != displayNameValue.type)
|
|
155
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNodeAttributesInvalid));
|
|
156
|
+
let writeMaskValue = (dataValues[3].statusCode.isGood() &&
|
|
157
|
+
dataValues[3].value.type == common_1.UaVariantType.UInt32) ? dataValues[3].value : undefined;
|
|
158
|
+
let descriptionValue = (returnDescription &&
|
|
159
|
+
dataValues[4].statusCode.isGood() &&
|
|
160
|
+
dataValues[4].value.type == common_1.UaVariantType.LocalizedText) ? dataValues[4].value : undefined;
|
|
161
|
+
let ret = {
|
|
162
|
+
nodeClass: nodeClassValue.value,
|
|
163
|
+
browseName: browseNameValue.value,
|
|
164
|
+
displayName: displayNameValue.value,
|
|
165
|
+
writeMask: (writeMaskValue) ? writeMaskValue.value : 0,
|
|
166
|
+
description: (descriptionValue) ? descriptionValue.value : undefined
|
|
167
|
+
};
|
|
168
|
+
return ret;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
readVariableAttributes(nodeIds) {
|
|
172
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
173
|
+
if (nodeIds.length == 0)
|
|
174
|
+
return [];
|
|
175
|
+
let nodesToRead = [];
|
|
176
|
+
for (let item of nodeIds) {
|
|
177
|
+
let nodeIdString = item.toString();
|
|
178
|
+
nodesToRead.push({ NodeId: nodeIdString, AttributeId: opcua_webapi_1.Attributes.NodeClass });
|
|
179
|
+
nodesToRead.push({ NodeId: nodeIdString, AttributeId: opcua_webapi_1.Attributes.DataType });
|
|
180
|
+
nodesToRead.push({ NodeId: nodeIdString, AttributeId: opcua_webapi_1.Attributes.ValueRank });
|
|
181
|
+
nodesToRead.push({ NodeId: nodeIdString, AttributeId: opcua_webapi_1.Attributes.AccessLevel });
|
|
182
|
+
nodesToRead.push({ NodeId: nodeIdString, AttributeId: opcua_webapi_1.Attributes.UserAccessLevel });
|
|
183
|
+
nodesToRead.push({ NodeId: nodeIdString, AttributeId: opcua_webapi_1.Attributes.Historizing });
|
|
184
|
+
}
|
|
185
|
+
let results = yield this.read(nodesToRead);
|
|
186
|
+
let dataValues = [];
|
|
187
|
+
let ret = [];
|
|
188
|
+
for (let item of results) {
|
|
189
|
+
dataValues.push(common_1.UaPayloadMapper.dataValueFromWebApi(item));
|
|
190
|
+
if (dataValues.length == 6) {
|
|
191
|
+
let dataType = common_1.UaNodeId.nullNodeId;
|
|
192
|
+
let valueRank = -1;
|
|
193
|
+
let accessLevel = 0;
|
|
194
|
+
let userAccessLevel = 0;
|
|
195
|
+
let historizing = false;
|
|
196
|
+
if (dataValues[0].statusCode.isGood() && dataValues[0].value.value == opcua_webapi_1.NodeClass.Variable) {
|
|
197
|
+
if (dataValues[1].statusCode.isGood() &&
|
|
198
|
+
dataValues[1].value.type == common_1.UaVariantType.NodeId)
|
|
199
|
+
dataType = dataValues[1].value.value;
|
|
200
|
+
if (dataValues[2].statusCode.isGood() &&
|
|
201
|
+
dataValues[2].value.type == common_1.UaVariantType.Int32)
|
|
202
|
+
valueRank = dataValues[2].value.value;
|
|
203
|
+
if (dataValues[3].statusCode.isGood() &&
|
|
204
|
+
dataValues[3].value.type == common_1.UaVariantType.Byte)
|
|
205
|
+
accessLevel = dataValues[3].value.value;
|
|
206
|
+
if (dataValues[4].statusCode.isGood() &&
|
|
207
|
+
dataValues[4].value.type == common_1.UaVariantType.Byte)
|
|
208
|
+
userAccessLevel = dataValues[4].value.value;
|
|
209
|
+
if (dataValues[5].statusCode.isGood() &&
|
|
210
|
+
dataValues[5].value.type == common_1.UaVariantType.Boolean)
|
|
211
|
+
historizing = dataValues[5].value.value;
|
|
212
|
+
}
|
|
213
|
+
ret.push({
|
|
214
|
+
dataType: dataType,
|
|
215
|
+
valueRank: valueRank,
|
|
216
|
+
accessLevel: accessLevel,
|
|
217
|
+
userAccessLevel: userAccessLevel,
|
|
218
|
+
historizing: historizing
|
|
219
|
+
});
|
|
220
|
+
dataValues = [];
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return ret;
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
readMethodArguments(nodeId) {
|
|
227
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
228
|
+
let ret = { inputArguments: [], outputArguments: [] };
|
|
229
|
+
let browseResult = yield this.browseChild(nodeId, opcua_webapi_1.NodeClass.Variable);
|
|
230
|
+
let inputArgumentsId = null;
|
|
231
|
+
let outputArgumentsId = null;
|
|
232
|
+
for (let item of browseResult.results) {
|
|
233
|
+
if ("InputArguments" == item.browseName)
|
|
234
|
+
inputArgumentsId = item.nodeId.getNodeId();
|
|
235
|
+
if ("OutputArguments" == item.browseName)
|
|
236
|
+
outputArgumentsId = item.nodeId.getNodeId();
|
|
237
|
+
}
|
|
238
|
+
let nodesToRead = [];
|
|
239
|
+
if (inputArgumentsId)
|
|
240
|
+
nodesToRead.push(inputArgumentsId);
|
|
241
|
+
if (outputArgumentsId)
|
|
242
|
+
nodesToRead.push(outputArgumentsId);
|
|
243
|
+
if (0 == nodesToRead.length)
|
|
244
|
+
return ret;
|
|
245
|
+
let readResults = yield this.readValues(nodesToRead);
|
|
246
|
+
let argsArr = [];
|
|
247
|
+
for (let item of readResults) {
|
|
248
|
+
if (item.statusCode.isNotGood() ||
|
|
249
|
+
common_1.UaVariantType.ExtensionObject != item.value.type ||
|
|
250
|
+
common_1.UaArrayType.Array != item.value.arrayType)
|
|
251
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadInvalidArgument));
|
|
252
|
+
let extensionObjects = item.value.value;
|
|
253
|
+
let args = [];
|
|
254
|
+
for (let itemL2 of extensionObjects) {
|
|
255
|
+
let arg = common_1.UaArgument.fromExtensionObject(itemL2);
|
|
256
|
+
if (!arg)
|
|
257
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadInvalidArgument));
|
|
258
|
+
args.push(arg);
|
|
259
|
+
}
|
|
260
|
+
argsArr.push(args);
|
|
261
|
+
}
|
|
262
|
+
if (inputArgumentsId && outputArgumentsId) {
|
|
263
|
+
ret.inputArguments = argsArr[0];
|
|
264
|
+
ret.outputArguments = argsArr[1];
|
|
265
|
+
}
|
|
266
|
+
else if (inputArgumentsId) {
|
|
267
|
+
ret.inputArguments = argsArr[0];
|
|
268
|
+
}
|
|
269
|
+
else if (outputArgumentsId) {
|
|
270
|
+
ret.outputArguments = argsArr[0];
|
|
271
|
+
}
|
|
272
|
+
return ret;
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
readObjectAttributes(nodeId) {
|
|
276
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
277
|
+
let nodeIdStr = nodeId.toString();
|
|
278
|
+
let nodesToRead = [
|
|
279
|
+
{ NodeId: nodeIdStr, AttributeId: opcua_webapi_1.Attributes.EventNotifier }
|
|
280
|
+
];
|
|
281
|
+
let results = yield this.read(nodesToRead);
|
|
282
|
+
let dataValues = [];
|
|
283
|
+
for (let item of results) {
|
|
284
|
+
dataValues.push(common_1.UaPayloadMapper.dataValueFromWebApi(item));
|
|
285
|
+
}
|
|
286
|
+
if (dataValues[0].statusCode.isNotGood())
|
|
287
|
+
throw new common_1.UaError(dataValues[0].statusCode);
|
|
288
|
+
let eventNotifierValue = dataValues[0].value;
|
|
289
|
+
if (common_1.UaVariantType.Byte != eventNotifierValue.type)
|
|
290
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadNodeAttributesInvalid));
|
|
291
|
+
let ret = {
|
|
292
|
+
eventNotifier: eventNotifierValue.value
|
|
293
|
+
};
|
|
294
|
+
return ret;
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
methodCall(objectId, methodId, inputArguments) {
|
|
298
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
299
|
+
let inputs = [];
|
|
300
|
+
for (let item of inputArguments) {
|
|
301
|
+
inputs.push(common_1.UaPayloadMapper.variantToWebApi(item));
|
|
302
|
+
}
|
|
303
|
+
let methodsToCall = [
|
|
304
|
+
{ ObjectId: objectId.toString(), MethodId: methodId.toString(), InputArguments: inputs }
|
|
305
|
+
];
|
|
306
|
+
let results = yield this.call(methodsToCall);
|
|
307
|
+
let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
|
|
308
|
+
if (statusCode.isNotGood())
|
|
309
|
+
throw new common_1.UaError(statusCode);
|
|
310
|
+
let outputs = [];
|
|
311
|
+
if (results[0].OutputArguments) {
|
|
312
|
+
for (let item of results[0].OutputArguments) {
|
|
313
|
+
outputs.push(common_1.UaPayloadMapper.variantFromWebApi(item));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return outputs;
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
getGeneratedEventType(typeId) {
|
|
320
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
321
|
+
let nodesToBrowse = {
|
|
322
|
+
NodeId: typeId.toString(),
|
|
323
|
+
BrowseDirection: opcua_webapi_1.BrowseDirection.Forward,
|
|
324
|
+
ReferenceTypeId: opcua_webapi_1.ReferenceTypeIds.GeneratesEvent,
|
|
325
|
+
IncludeSubtypes: false,
|
|
326
|
+
NodeClassMask: opcua_webapi_1.NodeClass.ObjectType,
|
|
327
|
+
ResultMask: 0
|
|
328
|
+
};
|
|
329
|
+
let results = yield this.browse([nodesToBrowse]);
|
|
330
|
+
let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
|
|
331
|
+
if (statusCode.isNotGood())
|
|
332
|
+
throw new common_1.UaError(statusCode);
|
|
333
|
+
let browseResult = common_1.UaPayloadMapper.browseResultFromWebApi(results[0]);
|
|
334
|
+
let ret = [];
|
|
335
|
+
for (let item of browseResult.results) {
|
|
336
|
+
ret.push(item.nodeId.getNodeId());
|
|
337
|
+
}
|
|
338
|
+
return ret;
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
historyReadRawData(nodeId, startTime, endTime, numValuesPerNode, continuationPoint, returnBounds, isReadModified, timestampsToReturn, releaseContinuationPoints) {
|
|
342
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
343
|
+
let nodeToRead = {
|
|
344
|
+
NodeId: nodeId.toString(),
|
|
345
|
+
ContinuationPoint: (continuationPoint) ? continuationPoint : undefined
|
|
346
|
+
};
|
|
347
|
+
let details = new common_2.UaReadRawModifiedDetails(startTime, endTime, numValuesPerNode, returnBounds, isReadModified);
|
|
348
|
+
let historyReadDetails = common_1.UaPayloadMapper.extensionObjectToWebApi(details.toExtensionObject());
|
|
349
|
+
let nodesToRead = [nodeToRead];
|
|
350
|
+
let results = yield this.historyRead(nodesToRead, historyReadDetails, timestampsToReturn, releaseContinuationPoints);
|
|
351
|
+
if (results.length != 1)
|
|
352
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadUnexpectedError));
|
|
353
|
+
let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
|
|
354
|
+
if (statusCode.isNotGood())
|
|
355
|
+
throw new common_1.UaError(statusCode);
|
|
356
|
+
let extensionObject = common_1.UaPayloadMapper.extensionObjectFromWebApi(results[0].HistoryData);
|
|
357
|
+
let historyData = common_1.UaHistoryData.fromExtensionObject(extensionObject);
|
|
358
|
+
if (null == historyData)
|
|
359
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
|
|
360
|
+
let ret = new common_1.UaHistoryDataResult(historyData.dataValues, results[0].ContinuationPoint);
|
|
361
|
+
return ret;
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
historyReadAtTime(nodeId, requiredTimes, useSimpleBounds, continuationPoint, timestampsToReturn, releaseContinuationPoints) {
|
|
365
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
366
|
+
if (requiredTimes.length == 0)
|
|
367
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadInvalidArgument));
|
|
368
|
+
let nodeToRead = {
|
|
369
|
+
NodeId: nodeId.toString(),
|
|
370
|
+
ContinuationPoint: (continuationPoint) ? continuationPoint : undefined
|
|
371
|
+
};
|
|
372
|
+
let details = new common_2.UaReadAtTimeDetails(requiredTimes, useSimpleBounds);
|
|
373
|
+
let historyReadDetails = common_1.UaPayloadMapper.extensionObjectToWebApi(details.toExtensionObject());
|
|
374
|
+
let nodesToRead = [nodeToRead];
|
|
375
|
+
let results = yield this.historyRead(nodesToRead, historyReadDetails, timestampsToReturn, releaseContinuationPoints);
|
|
376
|
+
if (results.length != 1)
|
|
377
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadUnexpectedError));
|
|
378
|
+
let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
|
|
379
|
+
if (statusCode.isNotGood())
|
|
380
|
+
throw new common_1.UaError(statusCode);
|
|
381
|
+
let extensionObject = common_1.UaPayloadMapper.extensionObjectFromWebApi(results[0].HistoryData);
|
|
382
|
+
let historyData = common_1.UaHistoryData.fromExtensionObject(extensionObject);
|
|
383
|
+
if (null == historyData)
|
|
384
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
|
|
385
|
+
let ret = new common_1.UaHistoryDataResult(historyData.dataValues, results[0].ContinuationPoint);
|
|
386
|
+
return ret;
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
historyReadEvent(nodeId, startTime, endTime, select, where, numValuesPerNode, continuationPoint, releaseContinuationPoints) {
|
|
390
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
391
|
+
if (select.length == 0)
|
|
392
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadInvalidArgument));
|
|
393
|
+
let nodeToRead = {
|
|
394
|
+
NodeId: nodeId.toString(),
|
|
395
|
+
ContinuationPoint: (continuationPoint) ? continuationPoint : undefined
|
|
396
|
+
};
|
|
397
|
+
let selectClauses = [];
|
|
398
|
+
let whereClauses = (where) ? where.toContentFilter() : null;
|
|
399
|
+
for (let item of select) {
|
|
400
|
+
let selectedField = new common_1.UaSimpleAttributeOperand([item]);
|
|
401
|
+
selectClauses.push(selectedField);
|
|
402
|
+
}
|
|
403
|
+
let details = new common_1.UaReadEventDetails(startTime, endTime, new common_1.UaEventFilter(selectClauses, whereClauses), numValuesPerNode);
|
|
404
|
+
let historyReadDetails = common_1.UaPayloadMapper.extensionObjectToWebApi(details.toExtensionObject());
|
|
405
|
+
let nodesToRead = [nodeToRead];
|
|
406
|
+
let results = yield this.historyRead(nodesToRead, historyReadDetails, opcua_webapi_1.TimestampsToReturn.Both, releaseContinuationPoints);
|
|
407
|
+
if (results.length != 1)
|
|
408
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadUnexpectedError));
|
|
409
|
+
let statusCode = common_1.UaPayloadMapper.statusCodeFromWebApi(results[0].StatusCode);
|
|
410
|
+
if (statusCode.isNotGood())
|
|
411
|
+
throw new common_1.UaError(statusCode);
|
|
412
|
+
let extensionObject = common_1.UaPayloadMapper.extensionObjectFromWebApi(results[0].HistoryData);
|
|
413
|
+
let historyData = common_2.UaHistoryEvent.fromExtensionObject(extensionObject);
|
|
414
|
+
if (null == historyData)
|
|
415
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDecodingError));
|
|
416
|
+
let ret = new common_2.UaHistoryEventResult(historyData.events, results[0].ContinuationPoint);
|
|
417
|
+
return ret;
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
// Native APIs
|
|
421
|
+
browse(nodesToBrowse, maxReferencesPerNode, view, additionalParameters) {
|
|
422
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
423
|
+
var _a, _b;
|
|
424
|
+
let request = (0, opcua_webapi_1.BrowseRequestFromJSON)({
|
|
425
|
+
RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
|
|
426
|
+
NodesToBrowse: nodesToBrowse,
|
|
427
|
+
RequestedMaxReferencesPerNode: (maxReferencesPerNode && maxReferencesPerNode > 0) ? maxReferencesPerNode : undefined,
|
|
428
|
+
View: view
|
|
429
|
+
});
|
|
430
|
+
let response = yield this.api.browse({ browseRequest: request });
|
|
431
|
+
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
432
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
433
|
+
if (!response.Results || nodesToBrowse.length != response.Results.length)
|
|
434
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
|
|
435
|
+
return response.Results;
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
browseNext(continuationPoints, releaseContinuationPoints, additionalParameters) {
|
|
439
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
440
|
+
var _a, _b;
|
|
441
|
+
let request = (0, opcua_webapi_1.BrowseNextRequestFromJSON)({
|
|
442
|
+
RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
|
|
443
|
+
ContinuationPoints: continuationPoints,
|
|
444
|
+
ReleaseContinuationPoints: releaseContinuationPoints
|
|
445
|
+
});
|
|
446
|
+
let response = yield this.api.browseNext({ browseNextRequest: request });
|
|
447
|
+
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
448
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
449
|
+
if (!response.Results || continuationPoints.length != response.Results.length)
|
|
450
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
|
|
451
|
+
return response.Results;
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
translate(browsePaths, additionalParameters) {
|
|
455
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
456
|
+
var _a, _b;
|
|
457
|
+
let request = (0, opcua_webapi_1.TranslateBrowsePathsToNodeIdsRequestFromJSON)({
|
|
458
|
+
RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
|
|
459
|
+
BrowsePaths: browsePaths
|
|
460
|
+
});
|
|
461
|
+
let response = yield this.api.translateBrowsePathsToNodeIds({ translateBrowsePathsToNodeIdsRequest: request });
|
|
462
|
+
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
463
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
464
|
+
if (!response.Results || browsePaths.length != response.Results.length)
|
|
465
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadUnknownResponse));
|
|
466
|
+
return response.Results;
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
read(nodesToRead, timestampsToReturn, maxAge, additionalParameters) {
|
|
470
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
471
|
+
var _a, _b;
|
|
472
|
+
let request = (0, opcua_webapi_1.ReadRequestFromJSON)({
|
|
473
|
+
RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
|
|
474
|
+
NodesToRead: nodesToRead,
|
|
475
|
+
MaxAge: (maxAge && maxAge > 0) ? maxAge : undefined,
|
|
476
|
+
TimestampsToReturn: (timestampsToReturn &&
|
|
477
|
+
timestampsToReturn >= opcua_webapi_1.TimestampsToReturn.Source &&
|
|
478
|
+
timestampsToReturn < opcua_webapi_1.TimestampsToReturn.Invalid) ? timestampsToReturn : undefined
|
|
479
|
+
});
|
|
480
|
+
let response = yield this.api.read({ readRequest: request });
|
|
481
|
+
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
482
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
483
|
+
if (!response.Results || nodesToRead.length != response.Results.length)
|
|
484
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
|
|
485
|
+
return response.Results;
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
write(nodesToWrite, additionalParameters) {
|
|
489
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
490
|
+
var _a, _b;
|
|
491
|
+
let request = (0, opcua_webapi_1.WriteRequestFromJSON)({
|
|
492
|
+
RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
|
|
493
|
+
NodesToWrite: nodesToWrite
|
|
494
|
+
});
|
|
495
|
+
let response = yield this.api.write({ writeRequest: request });
|
|
496
|
+
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
497
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
498
|
+
if (!response.Results || nodesToWrite.length != response.Results.length)
|
|
499
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
|
|
500
|
+
return response.Results;
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
call(methodsToCall, additionalParameters) {
|
|
504
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
505
|
+
var _a, _b;
|
|
506
|
+
let request = (0, opcua_webapi_1.CallRequestFromJSON)({
|
|
507
|
+
RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
|
|
508
|
+
MethodsToCall: methodsToCall
|
|
509
|
+
});
|
|
510
|
+
let response = yield this.api.call({ callRequest: request });
|
|
511
|
+
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
512
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
513
|
+
if (!response.Results || methodsToCall.length != response.Results.length)
|
|
514
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
|
|
515
|
+
return response.Results;
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
historyRead(nodesToRead, historyReadDetails, timestampsToReturn, releaseContinuationPoints, additionalParameters) {
|
|
519
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
520
|
+
var _a, _b;
|
|
521
|
+
let request = (0, opcua_webapi_1.HistoryReadRequestFromJSON)({
|
|
522
|
+
RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
|
|
523
|
+
HistoryReadDetails: historyReadDetails,
|
|
524
|
+
TimestampsToReturn: (timestampsToReturn &&
|
|
525
|
+
timestampsToReturn >= opcua_webapi_1.TimestampsToReturn.Source &&
|
|
526
|
+
timestampsToReturn < opcua_webapi_1.TimestampsToReturn.Invalid) ? timestampsToReturn : undefined,
|
|
527
|
+
ReleaseContinuationPoints: releaseContinuationPoints,
|
|
528
|
+
NodesToRead: nodesToRead
|
|
529
|
+
});
|
|
530
|
+
let response = yield this.api.historyRead({ historyReadRequest: request });
|
|
531
|
+
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
532
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
533
|
+
if (!response.Results || nodesToRead.length != response.Results.length)
|
|
534
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
|
|
535
|
+
return response.Results;
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
findServer(endpointUrl, serverUris, localeIds, additionalParameters) {
|
|
539
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
540
|
+
var _a, _b;
|
|
541
|
+
let request = (0, opcua_webapi_1.FindServersRequestFromJSON)({
|
|
542
|
+
RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
|
|
543
|
+
ServerUris: serverUris,
|
|
544
|
+
EndpointUrl: endpointUrl,
|
|
545
|
+
LocaleIds: localeIds
|
|
546
|
+
});
|
|
547
|
+
let response = yield this.api.findServers({ findServersRequest: request });
|
|
548
|
+
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
549
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
550
|
+
if (!response.Servers)
|
|
551
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
|
|
552
|
+
return response.Servers;
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
getEndpoints(endpointUrl, localeIds, profileUris, additionalParameters) {
|
|
556
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
557
|
+
var _a, _b;
|
|
558
|
+
let request = (0, opcua_webapi_1.GetEndpointsRequestFromJSON)({
|
|
559
|
+
RequestHeader: this.requestHeader(this.clientConfig, additionalParameters),
|
|
560
|
+
EndpointUrl: endpointUrl,
|
|
561
|
+
LocaleIds: localeIds,
|
|
562
|
+
ProfileUris: profileUris
|
|
563
|
+
});
|
|
564
|
+
let response = yield this.api.getEndpoints({ getEndpointsRequest: request });
|
|
565
|
+
if ((_b = (_a = response === null || response === void 0 ? void 0 : response.ResponseHeader) === null || _a === void 0 ? void 0 : _a.ServiceResult) === null || _b === void 0 ? void 0 : _b.Code)
|
|
566
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(response.ResponseHeader.ServiceResult.Code));
|
|
567
|
+
if (!response.Endpoints)
|
|
568
|
+
throw new common_1.UaError((0, common_1.makeUaStatusCode)(opcua_webapi_1.StatusCodes.BadDataLost));
|
|
569
|
+
return response.Endpoints;
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
requestHeader(clientConfig, additionalParameters) {
|
|
573
|
+
let timeout = clientConfig.defaultTimeout;
|
|
574
|
+
if (additionalParameters && additionalParameters.timeout)
|
|
575
|
+
timeout = additionalParameters.timeout;
|
|
576
|
+
let ret = {
|
|
577
|
+
RequestHandle: this.requestHandle,
|
|
578
|
+
TimeoutHint: timeout,
|
|
579
|
+
Timestamp: new Date(),
|
|
580
|
+
AuthenticationToken: this.authenticationToken,
|
|
581
|
+
ReturnDiagnostics: (additionalParameters) ? additionalParameters.returnDiagnostics : undefined,
|
|
582
|
+
AuditEntryId: (additionalParameters) ? additionalParameters.auditEntryId : undefined,
|
|
583
|
+
};
|
|
584
|
+
this.requestHandle++;
|
|
585
|
+
if (0xFFFFFFFF == this.requestHandle)
|
|
586
|
+
this.requestHandle = 1;
|
|
587
|
+
return ret;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
exports.UaWebClient = UaWebClient;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./UaWebClient"), exports);
|
|
18
|
+
__exportStar(require("./UaClientConfigure"), exports);
|
|
19
|
+
__exportStar(require("./utils"), exports);
|