UAMethod.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { XMLElem } from "@/util/XmlElem";
  2. import { UABaseNode, type UABaseNodeOptions } from "./UABaseNode";
  3. import type { NamespaceTable } from "./NameSpaceTable";
  4. import type { IAddressSpace } from "./IAddressSpace";
  5. export class UAMethod extends UABaseNode {
  6. public methodDeclarationId: string|undefined;
  7. public userExecutable!: Boolean;
  8. public executable!: Boolean;
  9. constructor(options: UAMethodNodeOptions) {
  10. super(options);
  11. Object.assign(this, options);
  12. this.nodeClass="UAMethod";
  13. }
  14. static fromXML(uaMethod: any, addressSpace: IAddressSpace): UAMethod{
  15. const bn=super.fromXML(uaMethod, addressSpace) as UAMethodNodeOptions;
  16. bn.methodDeclarationId=uaMethod['@_MethodDeclarationId'];
  17. bn.userExecutable=Boolean(uaMethod['@_UserExecutable']||true);
  18. bn.executable=Boolean(uaMethod['@_Executable']||true);
  19. return new UAMethod(bn as UABaseNodeOptions);
  20. }
  21. toXML(lnst:NamespaceTable, gnst:NamespaceTable): XMLElem {
  22. const elem =super.toXML(lnst, gnst);
  23. elem.name=this.nodeClass;
  24. elem.attr("MethodDeclarationId", this.methodDeclarationId);
  25. elem.attr("UserExecutable", this.userExecutable.toString());
  26. elem.attr("Executable", this.executable.toString());
  27. return elem;
  28. }
  29. }
  30. export interface UAMethodNodeOptions extends UABaseNodeOptions{
  31. methodDeclarationId?: string;
  32. userExecutable?: Boolean;
  33. executable?: Boolean;
  34. }