UNPKG

knxultimate

Version:

KNX IP protocol implementation for Node. This is the ENGINE of Node-Red KNX-Ultimate node.

120 lines 3.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const KnxLog_1 = require("../KnxLog"); const utils_1 = require("../utils"); const logger = (0, KnxLog_1.module)('DPT2'); const config = { id: 'DPT2', formatAPDU: (value) => { if (!value) { logger.error('cannot write null value'); return null; } let apdu_data; if (typeof value === 'object' && (0, utils_1.hasProp)(value, 'priority') && (0, utils_1.hasProp)(value, 'data')) { apdu_data = ((value.priority ? 1 : 0) << 1) | (value.data ? 1 : 0); return Buffer.from([apdu_data]); } logger.error('Must supply a value {priority:<bool>, data:<bool>}'); return null; }, fromBuffer: (buf) => { if (buf.length !== 1) { logger.error('Buffer should be 1 byte long, got', buf.length); return null; } return { priority: !!((buf[0] & 0b00000011) >> 1), data: !!(buf[0] & 0b00000001), }; }, basetype: { bitlength: 2, valuetype: 'composite', desc: '1-bit value with priority', help: `// Send a true/false with priority // priority = true or false // data = true or false msg.payload = {priority:false, data:true}; return msg;`, helplink: 'https://github.com/Supergiovane/node-red-contrib-knx-ultimate/wiki/-Sample---DPT2', }, subtypes: { '001': { use: 'G', name: 'Switch control', desc: 'switch with priority', enc: { 0: 'Off', 1: 'On' }, }, '002': { use: 'G', name: 'Bool control', desc: 'boolean with priority', enc: { 0: 'false', 1: 'true' }, }, '003': { use: 'FB', name: 'Enable control', desc: 'enable with priority', enc: { 0: 'Disabled', 1: 'Enabled' }, }, '004': { use: 'FB', name: 'Ramp control', desc: 'ramp with priority', enc: { 0: 'No ramp', 1: 'Ramp' }, }, '005': { use: 'FB', name: 'Alarm control', desc: 'alarm with priority', enc: { 0: 'No alarm', 1: 'Alarm' }, }, '006': { use: 'FB', name: 'Binary value control', desc: 'binary value with priority', enc: { 0: 'Off', 1: 'On' }, }, '007': { use: 'FB', name: 'Step control', desc: 'step with priority', enc: { 0: 'Off', 1: 'On' }, }, '008': { use: 'FB', name: 'Direction1 control', desc: 'direction 1 with priority', enc: { 0: 'Off', 1: 'On' }, }, '009': { use: 'FB', name: 'Direction2 control', desc: 'direction 2 with priority', enc: { 0: 'Off', 1: 'On' }, }, '010': { use: 'FB', name: 'Start control', desc: 'start with priority', enc: { 0: 'No control', 1: 'No control', 2: 'Off', 3: 'On' }, }, '011': { use: 'FB', name: 'State control', desc: 'state', enc: { 0: 'No control', 1: 'No control', 2: 'Off', 3: 'On' }, }, '012': { use: 'FB', name: 'Invert control', desc: 'invert', enc: { 0: 'No control', 1: 'No control', 2: 'Off', 3: 'On' }, }, }, }; exports.default = config; //# sourceMappingURL=dpt2.js.map