Ejemplo n.º 1
0
function ensureDataTypeString(dataType) {
    var dataTypeStr;

    if (typeof dataType === 'number') {
        dataTypeStr = zclId.dataType(dataType).key;
    } else if (typeof dataType === 'object' && dataType.hasOwnProperty('key')) {
        dataTypeStr = dataType.key;
    } else if (typeof dataType === 'string') {
        dataTypeStr = dataType;
    }
    return dataTypeStr;
}
Ejemplo n.º 2
0
    this.tap(name, function () {
        var type = zclId.dataType(this.vars.dataType).key,
            dataType;

        if (type === 'array' || type === 'set' || type === 'bag') {
            ru.attrVal()(this);
        } else if (type === 'struct') {
            ru.attrValStruct()(this);
        } else {
            flag = 1;
            ru.variable(name)(this);
        }
    }).tap(function () {
Ejemplo n.º 3
0
/*************************************************************************************************/
/*** Private Functions                                                                         ***/
/*************************************************************************************************/
function getChunkBuf (rule, arg) {
    var dataBuf = Concentrate(),
        type,
        i = 0;

    switch (rule) {
        case 'multi':
            type = zclId.dataType(arg.dataType).key;
            if (type === 'array' || type === 'set' || type === 'bag') {
                dataBuf = dataBuf.buffer(getChunkBuf('attrVal', arg.attrData));
            } else if (type === 'struct') {
                dataBuf = dataBuf.buffer(getChunkBuf('attrValStruct', arg.attrData));
            } else {
                dataBuf = dataBuf.buffer(getDataTypeBuf(getDataType(arg.dataType), arg.attrData));
            }
            return dataBuf.result();

        case 'attrVal': 
            dataBuf = dataBuf.uint8(arg.elmType).uint16(arg.numElms);
            for (i = 0; i < arg.numElms; i += 1) {
                dataBuf = dataBuf.buffer(getDataTypeBuf(getDataType(arg.elmType), arg.elmVals[i]));
            }
            return dataBuf.result();

        case 'attrValStruct': 
            dataBuf = dataBuf.uint16(arg.numElms);
            for (i = 0; i < arg.numElms; i += 1) {
                dataBuf = dataBuf.buffer(getChunkBuf('attrValStructNip', arg.structElms[i]));
            }
            return dataBuf.result();

        case 'attrValStructNip': 
            dataBuf = dataBuf.uint8(arg.elmType).buffer(getDataTypeBuf(getDataType(arg.elmType), arg.elmVal));
            return dataBuf.result();

        case 'selector':
            dataBuf = dataBuf.uint8(arg.indicator);

            for (i = 0; i < arg.indicator; i += 1) {
                dataBuf = dataBuf.uint16le(arg.indexes[i]);
            }
            return dataBuf.result();
    }
}
Ejemplo n.º 4
0
function isDataAnalogDigital(dataType) {
    var type = zclId.dataType(ensureDataTypeString(dataType)).value,
        analogDigital;

    if ((type > 0x07 && type < 0x20) ||  //GENERAL_DATA, LOGICAL, BITMAP
        (type > 0x2f && type < 0x38) ||  //ENUM
        (type > 0x3f && type < 0x58) ||  //STRING, ORDER_SEQ, COLLECTION
        (type > 0xe7 && type < 0xff))    //IDENTIFIER, MISC
    {
        analogDigital = 'DIGITAL';
    } else if (
        (type > 0x1f && type < 0x30) ||  //UNSIGNED_INT, SIGNED_INT
        (type > 0x37 && type < 0x40) ||  //FLOAT
        (type > 0xdf && type < 0xe8))    //TIME
    {
        analogDigital = 'ANALOG';
    }

    return analogDigital;
}