123456789101112131415161718192021222324252627282930313233343536 |
- import { BiMap } from "@/util/bi-map";
- export class NamespaceTable {
- OPC_UA = "http://opcfoundation.org/UA/";
- nsMap = new BiMap<number, string>();
- constructor() {
- this.nsMap.set(0, this.OPC_UA)
- }
- addUri(uri: string):number|undefined {
- if(this.nsMap.hasValue(uri)) {
- return this.nsMap.getFromValue(uri);
- } else {
- let index=1;
- while (this.nsMap.hasKey(index)) {
- index = index + 1;
- }
- this.nsMap.set(index, uri);
- return index;
- }
- }
- putUri(uri: string, index: number): void {
- this.nsMap.set(index, uri);
- }
- getUri(index: number): string|undefined {
- return this.nsMap.get(index);
- }
- getIndex(uri: string) : number|undefined {
- return this.nsMap.getFromValue(uri);
- }
- }
|