|
@@ -3,28 +3,56 @@ import { UABaseNode, type UABaseNodeOptions } from "./UABaseNode";
|
|
|
import type { NamespaceTable } from "./NameSpaceTable";
|
|
|
import type { IAddressSpace } from "./IAddressSpace";
|
|
|
|
|
|
-
|
|
|
-
|
|
|
export class UAVariable extends UABaseNode {
|
|
|
-
|
|
|
+ public parentNodeId?: string;
|
|
|
+ public dataType!: string;
|
|
|
+ public valueRank!: number;
|
|
|
+ public arrayDimensions?: string;
|
|
|
+ public accessLevel!: number;
|
|
|
+ public userAccessLevel!: number;
|
|
|
+ public minimumSamplingInterval!: number;
|
|
|
+ public historizing!: Boolean;
|
|
|
|
|
|
constructor(options: UAVariableNodeOptions) {
|
|
|
super(options);
|
|
|
+ Object.assign(this, options);
|
|
|
this.nodeClass="Variable";
|
|
|
}
|
|
|
|
|
|
static fromXML(uaObject: any, addressSpace: IAddressSpace): UAVariable{
|
|
|
- const bn=super.fromXML(uaObject, addressSpace)
|
|
|
+ const bn=super.fromXML(uaObject, addressSpace) as UAVariableNodeOptions
|
|
|
+ bn.parentNodeId=uaObject['ParentNodeId'];
|
|
|
+ bn.dataType=uaObject['@_DataType']||"i=24";
|
|
|
+ bn.valueRank=Number(uaObject['@_ValueRank']||-1);
|
|
|
+ bn.arrayDimensions=uaObject['@_ArrayDimensions'];
|
|
|
+ bn.accessLevel=Number(uaObject['@_AccessLevel']||1);
|
|
|
+ bn.userAccessLevel=Number(uaObject['@_UserAccessLevel']||1);
|
|
|
+ bn.minimumSamplingInterval=Number(uaObject['@_MinimumSamplingInterval']||0);
|
|
|
+ bn.historizing=Boolean(uaObject['@_Historizing']||false);
|
|
|
return new UAVariable(bn as UABaseNodeOptions);
|
|
|
}
|
|
|
|
|
|
toXML(lnst:NamespaceTable, gnst:NamespaceTable): XMLElem {
|
|
|
const elem=super.toXML(lnst, gnst);
|
|
|
+ elem.attr("ParentNodeId", this.parentNodeId);
|
|
|
+ elem.attr("DataType", this.dataType);
|
|
|
+ elem.attr("ValueRank", this.valueRank.toString());
|
|
|
+ elem.attr("ArrayDimensions", this.arrayDimensions);
|
|
|
+ elem.attr("AccessLevel", this.accessLevel.toString());
|
|
|
+ elem.attr("UserAccessLevel", this.userAccessLevel.toString());
|
|
|
+ elem.attr("MinimumSamplingInterval", this.minimumSamplingInterval.toString());
|
|
|
+ elem.attr("Historizing", this.historizing.toString());
|
|
|
return elem;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
export interface UAVariableNodeOptions extends UABaseNodeOptions{
|
|
|
-
|
|
|
+ parentNodeId?: string;
|
|
|
+ dataType?: string;
|
|
|
+ valueRank?: number;
|
|
|
+ arrayDimensions?: string;
|
|
|
+ accessLevel?: number;
|
|
|
+ userAccessLevel?: number;
|
|
|
+ minimumSamplingInterval?: number;
|
|
|
+ historizing?: Boolean;
|
|
|
}
|