UADataType.ts 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { XMLElem, type IToXML } from "@/util/XmlElem";
  2. import { type UABaseNodeOptions } from "./UABaseNode";
  3. import type { NamespaceTable } from "./NameSpaceTable";
  4. import type { IAddressSpace } from "./IAddressSpace";
  5. import { UAType } from "./UAType";
  6. import { Definition } from "./Definition";
  7. export class UADataType extends UAType implements IToXML {
  8. public definition?:Definition;
  9. constructor(options: UATypeOptions) {
  10. super(options);
  11. Object.assign(this, options);
  12. this.nodeClass="UADataType";
  13. this.definition=options.definition;
  14. }
  15. toXML(lnst:NamespaceTable, gnst:NamespaceTable): XMLElem {
  16. const elem=super.toXML(lnst, gnst);
  17. elem.name=this.nodeClass;
  18. elem.attr("Purpose", this.purpose);
  19. elem.attr('IsAbstract', this.isAbstract);
  20. elem.elem("Definition", this.definition?.toXML(lnst,gnst));
  21. return elem;
  22. }
  23. static fromXML(xmlObject: any, addressSpace: IAddressSpace): UADataType{
  24. const bn=super.fromXML(xmlObject, addressSpace) as UADataType;
  25. if(xmlObject['Definition'])
  26. bn.definition = Definition.fromXML(xmlObject['Definition'], addressSpace);
  27. return new UADataType(bn as UATypeOptions);
  28. }
  29. }
  30. export interface UATypeOptions extends UABaseNodeOptions{
  31. definition?:Definition;
  32. }