UAObject.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { XMLElem } from "@/util/XmlElem";
  2. import { UABaseNode, type UABaseNodeOptions } from "./UABaseNode";
  3. export class UAObject extends UABaseNode {
  4. constructor(options: UAObjectNodeOptions) {
  5. super(options);
  6. }
  7. static fromXML(uaObject: any): UAObject{
  8. const bn=super.fromXML(uaObject)
  9. return new UAObject({nodeId: bn.nodeId,
  10. browseName: bn.browseName,
  11. nodeClass: "Object",
  12. namespace: bn.namespace,
  13. displayName: bn.displayName,
  14. references: bn.references});
  15. }
  16. toXML(): XMLElem {
  17. const elem =new XMLElem('UAVariable');
  18. elem.attr('NodeID', this.nodeId.toString())
  19. .attr('BrowseName', this.browseName)
  20. .attr('DisplayName', this.displayName);
  21. const refs=elem.add(new XMLElem('References'))
  22. for(const ref of this.references) {
  23. refs.add(ref.toXML());
  24. }
  25. return elem;
  26. }
  27. }
  28. export interface UAObjectNodeOptions extends UABaseNodeOptions{
  29. }