dlms-protocol
Version:
DLMS Protocol parser for JavaScript
35 lines (33 loc) • 1.15 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
require("core-js/modules/es.parse-int.js");
require("core-js/modules/es.regexp.exec.js");
require("core-js/modules/es.string.match.js");
require("core-js/modules/esnext.iterator.map.js");
class CosemAddress {
constructor() {
let ClassId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
let InstanceId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
let AttributeId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
this.ClassId = ClassId;
this.InstanceId = InstanceId;
this.AttributeId = AttributeId;
}
// Convert a hex string to a byte array
hexStringToByteArray(hexString) {
return hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16));
}
get Classid() {
return this.hexStringToByteArray(this.ClassId);
}
get Instanceid() {
return this.hexStringToByteArray(this.InstanceId);
}
get Attributeid() {
return this.hexStringToByteArray(this.AttributeId);
}
}
var _default = exports.default = CosemAddress;