UAMethod.ts 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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="Method";
  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.attr("MethodDeclarationId", this.methodDeclarationId);
  24. elem.attr("UserExecutable", this.userExecutable.toString());
  25. elem.attr("Executable", this.executable.toString());
  26. return elem;
  27. }
  28. getModellingRule(){
  29. let res:any = "";
  30. this.references.forEach((ref)=>{
  31. if(ref.referenceType == "HasModellingRule"){
  32. res = ref.toNode.browseName;
  33. }
  34. })
  35. return res;
  36. }
  37. }
  38. export interface UAMethodNodeOptions extends UABaseNodeOptions{
  39. methodDeclarationId?: string;
  40. userExecutable?: Boolean;
  41. executable?: Boolean;
  42. }