UAType.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. import { XMLElem, type IToXML } 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 UAType extends UABaseNode implements IToXML {
  6. public purpose?: string
  7. public isAbstract?: boolean;
  8. constructor(options: UATypeOptions) {
  9. super(options);
  10. Object.assign(this, options);
  11. this.nodeClass="UAType";
  12. }
  13. toXML(lnst:NamespaceTable, gnst:NamespaceTable): XMLElem {
  14. const elem=super.toXML(lnst, gnst);
  15. elem.name=this.nodeClass;
  16. elem.attr("Purpose", this.purpose);
  17. elem.attr('IsAbstract', this.isAbstract);
  18. return elem;
  19. }
  20. static fromXML(uaObject: any, addressSpace: IAddressSpace): UAType{
  21. const bn=super.fromXML(uaObject, addressSpace) as UATypeOptions
  22. bn.purpose=uaObject['@_Purpose']||"Normal";
  23. bn.isAbstract=uaObject['@_IsAbstract']||false;
  24. return new UAType(bn as UATypeOptions);
  25. }
  26. }
  27. export interface UATypeOptions extends UABaseNodeOptions{
  28. purpose?:string;
  29. isAbstract?:string;
  30. }