Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9024dda
commit 1cd110f
Showing
1 changed file
with
84 additions
and
0 deletions.
There are no files selected for viewing
84 changes: 84 additions & 0 deletions
84
packages/node-opcua-address-space/test/test_extract_fields.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import fs from "fs"; | ||
import should from "should"; | ||
import { nodesets } from "node-opcua-nodesets"; | ||
import { checkDebugFlag, make_debugLog } from "node-opcua-debug"; | ||
|
||
import { extractFields, simpleBrowsePathsToString} from "node-opcua-pseudo-session"; | ||
|
||
import { generateAddressSpace } from "../nodeJS"; | ||
import { AddressSpace, PseudoSession } from ".."; | ||
import { resolveNodeId } from "node-opcua-nodeid"; | ||
|
||
const debugLog = make_debugLog("TEST"); | ||
const doDebug = checkDebugFlag("TEST"); | ||
|
||
describe("extractFields", () => { | ||
let addressSpace: AddressSpace; | ||
before(async () => { | ||
const xmlFiles = [nodesets.standard, nodesets.di, nodesets.autoId]; | ||
addressSpace = AddressSpace.create(); | ||
fs.existsSync(xmlFiles[0]).should.eql(true); | ||
await generateAddressSpace(addressSpace, xmlFiles); | ||
addressSpace.registerNamespace("urn:OwnNamespace"); | ||
}); | ||
after(() => { | ||
addressSpace.dispose(); | ||
}); | ||
|
||
describe("testing extractFields", () => { | ||
it("on AutoIdScanEventType", async () => { | ||
// | ||
const nsAuditId = addressSpace.getNamespace("http://opcfoundation.org/UA/AutoID/"); | ||
should.exist(nsAuditId, "expecting to find AutoID namespace"); | ||
const AutoIdScanEventType = nsAuditId.findObjectType("AutoIdScanEventType"); | ||
if (!AutoIdScanEventType) throw new Error(""); | ||
const session = new PseudoSession(addressSpace); | ||
const e = await extractFields(session, AutoIdScanEventType.nodeId); | ||
|
||
const b = simpleBrowsePathsToString(e.map((a) => a.path)); | ||
b.sort().should.eql([ | ||
"2:DeviceName", | ||
"2:ScanResult", | ||
"ConditionClassId", | ||
"ConditionClassName", | ||
"ConditionSubClassId", | ||
"ConditionSubClassName", | ||
"EventId", | ||
"EventType", | ||
"LocalTime", | ||
"Message", | ||
"ReceiveTime", | ||
"Severity", | ||
"SourceName", | ||
"SourceNode", | ||
"Time" | ||
]); | ||
}); | ||
it("on TransitionEventType", async () => { | ||
const session = new PseudoSession(addressSpace); | ||
const e = await extractFields(session, resolveNodeId("TransitionEventType")); | ||
const b = simpleBrowsePathsToString(e.map((a) => a.path)); | ||
b.sort().should.eql([ | ||
"ConditionClassId", | ||
"ConditionClassName", | ||
"ConditionSubClassId", | ||
"ConditionSubClassName", | ||
"EventId", | ||
"EventType", | ||
"FromState", | ||
"FromState.Id", | ||
"LocalTime", | ||
"Message", | ||
"ReceiveTime", | ||
"Severity", | ||
"SourceName", | ||
"SourceNode", | ||
"Time", | ||
"ToState", | ||
"ToState.Id", | ||
"Transition", | ||
"Transition.Id" | ||
]); | ||
}); | ||
}); | ||
}); |