Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | 55x 110x 55x 55x 55x 55x 55x 55x 55x 55x 55x 72x 72x 72x 36x 36x 36x 36x 34x 2x 2x 2x 2x 2x 36x 36x 36x 36x 36x 34x 2x 2x 2x 2x 2x 2x 2x 55x | "use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importStar = (this && this.__importStar) || function (mod) {
Eif (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const Bucket_1 = __importDefault(require("./Bucket"));
const factory_1 = __importDefault(require("./factory"));
const id_1 = require("../id/id");
const ExpandedNodeId_1 = __importStar(require("./ExpandedNodeId"));
exports.ExtensionObjectEmpty = 0;
exports.ExtensionObjectBinary = 1;
// https://reference.opcfoundation.org/v104/Core/docs/Part6/5.2.2/#5.2.2.15
class ExtensionObject {
constructor(options) {
var _a, _b, _c, _d, _e, _f;
this.TypeId = (_b = (_a = options) === null || _a === void 0 ? void 0 : _a.TypeId, (_b !== null && _b !== void 0 ? _b : ExpandedNodeId_1.NewTwoByteExpandedNodeId(0)));
this.Encoding = (_d = (_c = options) === null || _c === void 0 ? void 0 : _c.Encoding, (_d !== null && _d !== void 0 ? _d : 0));
this.Value = (_f = (_e = options) === null || _e === void 0 ? void 0 : _e.Value, (_f !== null && _f !== void 0 ? _f : null));
}
encode() {
const bucket = new Bucket_1.default();
bucket.writeStruct(this.TypeId);
bucket.writeUint8(this.Encoding);
if (this.Encoding == exports.ExtensionObjectEmpty) {
return bucket.bytes;
}
const body = new Bucket_1.default();
body.writeStruct(this.Value);
bucket.writeUint32(body.bytes.byteLength);
bucket.write(body.bytes);
return bucket.bytes;
}
decode(b, position) {
const bucket = new Bucket_1.default(b, position);
this.TypeId = new ExpandedNodeId_1.default();
bucket.readStruct(this.TypeId);
this.Encoding = bucket.readUint8();
if (this.Encoding === exports.ExtensionObjectEmpty) {
return bucket.position;
}
const length = bucket.readUint32();
Iif (length === 0 || length === 0xffffffff) {
return bucket.position;
}
const name = id_1.map.get(this.TypeId.NodeId.Identifier);
Iif (name === undefined) {
throw new Error(`invalid extension object with id ${this.TypeId.NodeId.Identifier}`);
}
this.Value = factory_1.default(name);
bucket.readStruct(this.Value);
return bucket.position;
}
}
exports.default = ExtensionObject;
|