import { XMLElem } from "@/util/XmlElem"; import { UABaseNode, type UABaseNodeOptions } from "./UABaseNode"; import type { NamespaceTable } from "./NameSpaceTable"; import type { IAddressSpace } from "./IAddressSpace"; export class UAMethod extends UABaseNode { public methodDeclarationId: string|undefined; public userExecutable!: Boolean; public executable!: Boolean; constructor(options: UAMethodNodeOptions) { super(options); Object.assign(this, options); this.nodeClass="Method"; } static fromXML(uaMethod: any, addressSpace: IAddressSpace): UAMethod{ const bn=super.fromXML(uaMethod, addressSpace) as UAMethodNodeOptions; bn.methodDeclarationId=uaMethod['@_MethodDeclarationId']; bn.userExecutable=Boolean(uaMethod['@_UserExecutable']||true); bn.executable=Boolean(uaMethod['@_Executable']||true); return new UAMethod(bn as UABaseNodeOptions); } toXML(lnst:NamespaceTable, gnst:NamespaceTable): XMLElem { const elem =super.toXML(lnst, gnst); elem.attr("MethodDeclarationId", this.methodDeclarationId); elem.attr("UserExecutable", this.userExecutable.toString()); elem.attr("Executable", this.executable.toString()); return elem; } getModellingRule(){ let res:any = ""; this.references.forEach((ref)=>{ if(ref.referenceType == "HasModellingRule"){ res = ref.toNode.browseName; } }) return res; } } export interface UAMethodNodeOptions extends UABaseNodeOptions{ methodDeclarationId?: string; userExecutable?: Boolean; executable?: Boolean; }