UAMethod.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. getModellingRule(){
  30. let res:any = "";
  31. this.references.forEach((ref)=>{
  32. if(ref.referenceType == "HasModellingRule"){
  33. res = ref.toNode.browseName;
  34. }
  35. })
  36. return res;
  37. }
  38. }
  39. export interface UAMethodNodeOptions extends UABaseNodeOptions{
  40. methodDeclarationId?: string;
  41. userExecutable?: Boolean;
  42. executable?: Boolean;
  43. }