klf-200-api
Version:
This module provides a wrapper to the socket API of a Velux KLF-200 interface. You will need at least firmware 0.2.0.0.71 on your KLF interface for this library to work.
24 lines • 977 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.FrameRcvFactory = void 0;
const path_1 = require("path");
const common_js_1 = require("./common.js");
class FrameRcvFactory {
static async CreateRcvFrame(Buff) {
const CommandName = common_js_1.GatewayCommand[Buff.readUInt16BE(1)];
await this.LoadModule(CommandName);
const typeToCreate = this.modules[CommandName][CommandName];
if (typeToCreate === undefined)
throw new Error(`Unknown command ${CommandName}.`);
return new typeToCreate(Buff);
}
static modules = {};
static async LoadModule(moduleName) {
if (!this.modules[moduleName]) {
let modulePath = (0, path_1.resolve)(__dirname, moduleName);
this.modules[moduleName] = await Promise.resolve(`${modulePath}`).then(s => require(s));
}
}
}
exports.FrameRcvFactory = FrameRcvFactory;
//# sourceMappingURL=FrameRcvFactory.js.map
;