UAVariable.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 UAVariable extends UABaseNode {
  6. public parentNodeId?: string;
  7. public dataType!: string;
  8. public valueRank!: number;
  9. public arrayDimensions?: string;
  10. public accessLevel!: number;
  11. public userAccessLevel!: number;
  12. public minimumSamplingInterval!: number;
  13. public historizing!: Boolean;
  14. constructor(options: UAVariableNodeOptions) {
  15. super(options);
  16. Object.assign(this, options);
  17. this.nodeClass="Variable";
  18. }
  19. static fromXML(uaObject: any, addressSpace: IAddressSpace): UAVariable{
  20. const bn=super.fromXML(uaObject, addressSpace) as UAVariableNodeOptions
  21. bn.parentNodeId=uaObject['ParentNodeId'];
  22. bn.dataType=uaObject['@_DataType']||"i=24";
  23. bn.valueRank=Number(uaObject['@_ValueRank']||-1);
  24. bn.arrayDimensions=uaObject['@_ArrayDimensions'];
  25. bn.accessLevel=Number(uaObject['@_AccessLevel']||1);
  26. bn.userAccessLevel=Number(uaObject['@_UserAccessLevel']||1);
  27. bn.minimumSamplingInterval=Number(uaObject['@_MinimumSamplingInterval']||0);
  28. bn.historizing=Boolean(uaObject['@_Historizing']||false);
  29. return new UAVariable(bn as UABaseNodeOptions);
  30. }
  31. toXML(lnst:NamespaceTable, gnst:NamespaceTable): XMLElem {
  32. const elem=super.toXML(lnst, gnst);
  33. elem.attr("ParentNodeId", this.parentNodeId);
  34. elem.attr("DataType", this.dataType);
  35. elem.attr("ValueRank", this.valueRank.toString());
  36. elem.attr("ArrayDimensions", this.arrayDimensions);
  37. elem.attr("AccessLevel", this.accessLevel.toString());
  38. elem.attr("UserAccessLevel", this.userAccessLevel.toString());
  39. elem.attr("MinimumSamplingInterval", this.minimumSamplingInterval.toString());
  40. elem.attr("Historizing", this.historizing.toString());
  41. return elem;
  42. }
  43. }
  44. export interface UAVariableNodeOptions extends UABaseNodeOptions{
  45. parentNodeId?: string;
  46. dataType?: string;
  47. valueRank?: number;
  48. arrayDimensions?: string;
  49. accessLevel?: number;
  50. userAccessLevel?: number;
  51. minimumSamplingInterval?: number;
  52. historizing?: Boolean;
  53. }