UAObject.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { XMLElem } from "@/util/XmlElem";
  2. import type { NamespaceTable } from "./NameSpaceTable";
  3. import { UABaseNode, type UABaseNodeOptions } from "./UABaseNode";
  4. import type { IAddressSpace } from "./IAddressSpace";
  5. export class UAObject extends UABaseNode {
  6. public parentNodeId?: string;
  7. public eventNotifier: number=0;
  8. constructor(options: UAObjectNodeOptions) {
  9. super(options);
  10. Object.assign(this, options);
  11. this.nodeClass="Object";
  12. }
  13. static fromXML(uaObject: any, addressSpace: IAddressSpace): UAObject{
  14. const bn=super.fromXML(uaObject, addressSpace) as UAObjectNodeOptions;
  15. bn.parentNodeId=uaObject['@_ParentNodeId'];
  16. bn.eventNotifier=Number(uaObject['@_EventNotifier']||0);
  17. return new UAObject(bn as UAObjectNodeOptions);
  18. }
  19. toXML(lnst:NamespaceTable, gnst:NamespaceTable): XMLElem {
  20. const elem =super.toXML(lnst, gnst);
  21. elem.attr("ParentNodeId", this.parentNodeId);
  22. elem.attr("EventNotifier", this.eventNotifier?.toString());
  23. return elem;
  24. }
  25. }
  26. export interface UAObjectNodeOptions extends UABaseNodeOptions{
  27. parentNodeId?: string;
  28. eventNotifier?: number;
  29. }