UAObject.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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="UAObject";
  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.name=this.nodeClass;
  22. elem.attr("ParentNodeId", this.parentNodeId);
  23. elem.attr("EventNotifier", this.eventNotifier?.toString());
  24. return elem;
  25. }
  26. }
  27. export interface UAObjectNodeOptions extends UABaseNodeOptions{
  28. parentNodeId?: string;
  29. eventNotifier?: number;
  30. }