UAVariable.ts 1.1 KB

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