(function (global, factory) {
    typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@iotize/tap/client/impl'), require('@iotize/tap/client/api'), require('@iotize/tap/service/core'), require('@iotize/tap/service/impl/bundle'), require('@iotize/tap')) :
    typeof define === 'function' && define.amd ? define('@iotize/tap/service/impl/variable', ['exports', '@iotize/tap/client/impl', '@iotize/tap/client/api', '@iotize/tap/service/core', '@iotize/tap/service/impl/bundle', '@iotize/tap'], factory) :
    (global = global || self, factory((global.iotize = global.iotize || {}, global.iotize.tap = global.iotize.tap || {}, global.iotize.tap.service = global.iotize.tap.service || {}, global.iotize.tap.service.impl = global.iotize.tap.service.impl || {}, global.iotize.tap.service.impl.variable = {}), global.iotize.tap.client.impl, global.iotize.tap.client.api, global.iotize.tap.service.core, global.iotize.tap.service.impl.bundle, global.iotize.tap));
}(this, (function (exports, impl, api, core, bundle, tap) { 'use strict';

    (function (VariableType) {
        /* tslint:disable */
        /**
         * This file was automatically generated by json-schema-to-typescript.
         * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
         * and run json-schema-to-typescript to regenerate this file.
         */
        var Data;
        (function (Data) {
            Data[Data["BOOLEAN"] = 0] = "BOOLEAN";
            Data[Data["INT8"] = 1] = "INT8";
            Data[Data["INT16"] = 2] = "INT16";
            Data[Data["INT32"] = 3] = "INT32";
            Data[Data["ASCII"] = 8] = "ASCII";
            Data[Data["FLOAT32"] = 19] = "FLOAT32";
            Data[Data["UINT8"] = 33] = "UINT8";
            Data[Data["UINT16"] = 34] = "UINT16";
            Data[Data["UINT32"] = 35] = "UINT32";
        })(Data = VariableType.Data || (VariableType.Data = {}));
        /* tslint:disable */
        /**
         * This file was automatically generated by json-schema-to-typescript.
         * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
         * and run json-schema-to-typescript to regenerate this file.
         */
        var Domain;
        (function (Domain) {
            Domain[Domain["TARGET"] = 0] = "TARGET";
            Domain[Domain["GPIO"] = 1] = "GPIO";
            Domain[Domain["IN_TAP_STATIC"] = 2] = "IN_TAP_STATIC";
            Domain[Domain["IN_TAP_VOLATIL"] = 3] = "IN_TAP_VOLATIL";
        })(Domain = VariableType.Domain || (VariableType.Domain = {}));
    })(exports.VariableType || (exports.VariableType = {}));

    /**
     *   Generated file. Do not edit
     */
    impl.TapStreamReader.prototype.readModbusVariableAddress = function () {
        var model = {};
        model.functionCode = this.readUnsigned(1);
        model.slave = this.readUnsigned(1);
        model.address = this.readUnsigned(2);
        return model;
    };
    impl.TapStreamReader.prototype.readVariableType = function () {
        var model = {};
        model.domain = this.readBits(2);
        model.data = this.readBits(6);
        return model;
    };
    impl.TapStreamReader.prototype.readVariableMeta = function () {
        var model = {};
        model.name = this.readStringTerminator(":");
        model.unit = this.readString();
        return model;
    };
    // TapStreamWriter.prototype.write(model: ModbusVariableAddress) : TapStreamWriter{
    //     return this.writeModbusVariableAddress(model)
    // }
    impl.TapStreamWriter.prototype.writeModbusVariableAddress = function (model) {
        this.writeUnsigned(model.functionCode, 1);
        this.writeUnsigned(model.slave, 1);
        this.writeUnsigned(model.address, 2);
        return this;
    };
    // TapStreamWriter.prototype.write(model: VariableType) : TapStreamWriter{
    //     return this.writeVariableType(model)
    // }
    impl.TapStreamWriter.prototype.writeVariableType = function (model) {
        this.writeBitsInt(impl.enumKeyOrValueToNumber(model.domain, exports.VariableType.Domain), 2);
        this.writeBitsInt(impl.enumKeyOrValueToNumber(model.data, exports.VariableType.Data), 6);
        return this;
    };
    // TapStreamWriter.prototype.write(model: VariableMeta) : TapStreamWriter{
    //     return this.writeVariableMeta(model)
    // }
    impl.TapStreamWriter.prototype.writeVariableMeta = function (model) {
        this.writeString(model.name + ":");
        this.writeString(model.unit);
        return this;
    };

    /**
     *   Generated file. Do not edit
     */
    var ModbusVariableAddressConverter = /** @class */ (function () {
        function ModbusVariableAddressConverter() {
        }
        ModbusVariableAddressConverter.prototype.encode = function (model, stream) {
            if (stream === void 0) { stream = new impl.TapStreamWriter(); }
            stream.writeModbusVariableAddress(model);
            return stream.toBytes;
        };
        ModbusVariableAddressConverter.prototype.decode = function (data) {
            var stream = data instanceof impl.TapStreamReader ? data : impl.TapStreamReader.create(data);
            return stream.readModbusVariableAddress();
        };
        return ModbusVariableAddressConverter;
    }());
    var VariableTypeConverter = /** @class */ (function () {
        function VariableTypeConverter() {
        }
        VariableTypeConverter.prototype.encode = function (model, stream) {
            if (stream === void 0) { stream = new impl.TapStreamWriter(); }
            stream.writeVariableType(model);
            return stream.toBytes;
        };
        VariableTypeConverter.prototype.decode = function (data) {
            var stream = data instanceof impl.TapStreamReader ? data : impl.TapStreamReader.create(data);
            return stream.readVariableType();
        };
        return VariableTypeConverter;
    }());
    var VariableMetaConverter = /** @class */ (function () {
        function VariableMetaConverter() {
        }
        VariableMetaConverter.prototype.encode = function (model, stream) {
            if (stream === void 0) { stream = new impl.TapStreamWriter(); }
            stream.writeVariableMeta(model);
            return stream.toBytes;
        };
        VariableMetaConverter.prototype.decode = function (data) {
            var stream = data instanceof impl.TapStreamReader ? data : impl.TapStreamReader.create(data);
            return stream.readVariableMeta();
        };
        return VariableMetaConverter;
    }());

    /**
     *   Generated file. Do not edit
     */
    var modbusVariableAddress = new ModbusVariableAddressConverter();
    var variableType = new VariableTypeConverter();
    var variableMeta = new VariableMetaConverter();

    var serviceConverters = /*#__PURE__*/Object.freeze({
        __proto__: null,
        modbusVariableAddress: modbusVariableAddress,
        variableType: variableType,
        variableMeta: variableMeta
    });

    /**
     *   Generated file. Do not edit
     */
    var __assign = (this && this.__assign) || function () {
        __assign = Object.assign || function(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                    t[p] = s[p];
            }
            return t;
        };
        return __assign.apply(this, arguments);
    };
    var allConverters = __assign(__assign(__assign({}, core.converters), serviceConverters), bundle.bundleConverters);
    var SERVICE_CALLS = {
        getVariableAddress: {
            method: api.TapRequestFrame.MethodType.GET,
            pathAlias: "/variable/{variableId}/variable-address",
            path: "/1029/{variableId}/0",
            responseBodyDecoder: allConverters.uint32
        },
        putVariableAddress: {
            method: api.TapRequestFrame.MethodType.PUT,
            pathAlias: "/variable/{variableId}/variable-address",
            path: "/1029/{variableId}/0",
            bodyEncoder: allConverters.uint32
        },
        putModbusVariableAddress: {
            method: api.TapRequestFrame.MethodType.PUT,
            pathAlias: "/variable/{variableId}/modbus-variable-address",
            path: "/1029/{variableId}/0",
            bodyEncoder: allConverters.modbusVariableAddress
        },
        getType: {
            method: api.TapRequestFrame.MethodType.GET,
            pathAlias: "/variable/{variableId}/type",
            path: "/1029/{variableId}/1",
            responseBodyDecoder: allConverters.variableType
        },
        putType: {
            method: api.TapRequestFrame.MethodType.PUT,
            pathAlias: "/variable/{variableId}/type",
            path: "/1029/{variableId}/1",
            bodyEncoder: allConverters.variableType
        },
        getRawMeta: {
            method: api.TapRequestFrame.MethodType.GET,
            pathAlias: "/variable/{variableId}/raw-meta",
            path: "/1029/{variableId}/8"
        },
        putRawMeta: {
            method: api.TapRequestFrame.MethodType.PUT,
            pathAlias: "/variable/{variableId}/raw-meta",
            path: "/1029/{variableId}/8"
        },
        getMeta: {
            method: api.TapRequestFrame.MethodType.GET,
            pathAlias: "/variable/{variableId}/meta",
            path: "/1029/{variableId}/8",
            responseBodyDecoder: allConverters.variableMeta
        },
        putMeta: {
            method: api.TapRequestFrame.MethodType.PUT,
            pathAlias: "/variable/{variableId}/meta",
            path: "/1029/{variableId}/8",
            bodyEncoder: allConverters.variableMeta
        },
        getUnit: {
            method: api.TapRequestFrame.MethodType.GET,
            pathAlias: "/variable/{variableId}/unit",
            path: "/1029/{variableId}/9",
            responseBodyDecoder: allConverters.ascii
        },
        putUnit: {
            method: api.TapRequestFrame.MethodType.PUT,
            pathAlias: "/variable/{variableId}/unit",
            path: "/1029/{variableId}/9",
            bodyEncoder: allConverters.ascii
        },
        getNumberOfElements: {
            method: api.TapRequestFrame.MethodType.GET,
            pathAlias: "/variable/{variableId}/number-of-elements",
            path: "/1029/{variableId}/2",
            responseBodyDecoder: allConverters.uint8
        },
        putNumberOfElements: {
            method: api.TapRequestFrame.MethodType.PUT,
            pathAlias: "/variable/{variableId}/number-of-elements",
            path: "/1029/{variableId}/2",
            bodyEncoder: allConverters.uint8
        },
        getCurrentAccess: {
            method: api.TapRequestFrame.MethodType.GET,
            pathAlias: "/variable/{variableId}/current-access",
            path: "/1029/{variableId}/3",
            responseBodyDecoder: allConverters.readWriteRights
        },
        readProfile: {
            method: api.TapRequestFrame.MethodType.GET,
            pathAlias: "/variable/read-profile",
            path: "/1029//4"
        },
        getValue: {
            method: api.TapRequestFrame.MethodType.GET,
            pathAlias: "/variable/{variableId}/value",
            path: "/1029/{variableId}/4"
        },
        setValue: {
            method: api.TapRequestFrame.MethodType.POST,
            pathAlias: "/variable/{variableId}/value",
            path: "/1029/{variableId}/5"
        },
        putValue: {
            method: api.TapRequestFrame.MethodType.PUT,
            pathAlias: "/variable/{variableId}/value",
            path: "/1029/{variableId}/4"
        },
        getBundleId: {
            method: api.TapRequestFrame.MethodType.GET,
            pathAlias: "/variable/{variableId}/bundle/id",
            path: "/1029/{variableId}/6",
            responseBodyDecoder: allConverters.uint16
        },
        putBundleId: {
            method: api.TapRequestFrame.MethodType.PUT,
            pathAlias: "/variable/{variableId}/bundle/id",
            path: "/1029/{variableId}/6",
            bodyEncoder: allConverters.uint16
        },
        getBundleValues: {
            method: api.TapRequestFrame.MethodType.GET,
            pathAlias: "/variable/{variableId}/bundle/values",
            path: "/1029/{variableId}/7"
        },
        create: {
            method: api.TapRequestFrame.MethodType.POST,
            pathAlias: "/variable/{variableId}/create",
            path: "/1029/{variableId}/65535",
            bodyEncoder: allConverters.uint8
        }
    };

    var __extends = (this && this.__extends) || (function () {
        var extendStatics = function (d, b) {
            extendStatics = Object.setPrototypeOf ||
                ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
                function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
            return extendStatics(d, b);
        };
        return function (d, b) {
            extendStatics(d, b);
            function __() { this.constructor = d; }
            d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
        };
    })();
    var __assign$1 = (this && this.__assign) || function () {
        __assign$1 = Object.assign || function(t) {
            for (var s, i = 1, n = arguments.length; i < n; i++) {
                s = arguments[i];
                for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                    t[p] = s[p];
            }
            return t;
        };
        return __assign$1.apply(this, arguments);
    };
    var VariableService = /** @class */ (function (_super) {
        __extends(VariableService, _super);
        function VariableService() {
            var _this = _super !== null && _super.apply(this, arguments) || this;
            _this.resources = SERVICE_CALLS;
            return _this;
        }
        /**
         * Get variable address
         *
         * LWM2M path: /1029/{variableId}/0
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return
         */
        VariableService.prototype.getVariableAddress = function (
        /*
         * ID of the variable
         */
        variableId) {
            return this.serviceCallRunner.execute(this.getVariableAddressCall(variableId));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/0
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return call options
         */
        VariableService.prototype.getVariableAddressCall = function (
        /*
         * ID of the variable
         */
        variableId) {
            var callOptions = __assign$1({}, this.resources.getVariableAddress);
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Write variable address
         *
         * LWM2M path: /1029/{variableId}/0
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param address input
         * @return
         */
        VariableService.prototype.putVariableAddress = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * New address of the variable
         */
        address) {
            return this.serviceCallRunner.execute(this.putVariableAddressCall(variableId, address));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/0
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param address input
         * @return call options
         */
        VariableService.prototype.putVariableAddressCall = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * New address of the variable
         */
        address) {
            var callOptions = __assign$1({}, this.resources.putVariableAddress);
            callOptions.body = address;
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Write modbus variable address
         *
         * LWM2M path: /1029/{variableId}/0
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param address input
         * @return
         */
        VariableService.prototype.putModbusVariableAddress = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * New address of the variable
         */
        address) {
            return this.serviceCallRunner.execute(this.putModbusVariableAddressCall(variableId, address));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/0
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param address input
         * @return call options
         */
        VariableService.prototype.putModbusVariableAddressCall = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * New address of the variable
         */
        address) {
            var callOptions = __assign$1({}, this.resources.putModbusVariableAddress);
            callOptions.body = address;
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Get data type for variable
         *
         * LWM2M path: /1029/{variableId}/1
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return
         */
        VariableService.prototype.getType = function (
        /*
         * ID of the variable
         */
        variableId) {
            return this.serviceCallRunner.execute(this.getTypeCall(variableId));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/1
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return call options
         */
        VariableService.prototype.getTypeCall = function (
        /*
         * ID of the variable
         */
        variableId) {
            var callOptions = __assign$1({}, this.resources.getType);
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Get data type for variable
         *
         * LWM2M path: /1029/{variableId}/1
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param type input
         * @return
         */
        VariableService.prototype.putType = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * variable type
         */
        type) {
            return this.serviceCallRunner.execute(this.putTypeCall(variableId, type));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/1
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param type input
         * @return call options
         */
        VariableService.prototype.putTypeCall = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * variable type
         */
        type) {
            var callOptions = __assign$1({}, this.resources.putType);
            callOptions.body = type;
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Get variable meta
         *
         * LWM2M path: /1029/{variableId}/8
         *
         * @tapVersion(">=1.73")
         * @param variableId input
         * @return
         */
        VariableService.prototype.getRawMeta = function (
        /*
         * ID of the variable
         */
        variableId) {
            return this.serviceCallRunner.execute(this.getRawMetaCall(variableId));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/8
         *
         * @tapVersion(">=1.73")
         * @param variableId input
         * @return call options
         */
        VariableService.prototype.getRawMetaCall = function (
        /*
         * ID of the variable
         */
        variableId) {
            var callOptions = __assign$1({}, this.resources.getRawMeta);
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Write variable meta
         *
         * LWM2M path: /1029/{variableId}/8
         *
         * @tapVersion(">=1.73")
         * @param variableId input
         * @param meta input
         * @return
         */
        VariableService.prototype.putRawMeta = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * Variable meta
         */
        meta) {
            return this.serviceCallRunner.execute(this.putRawMetaCall(variableId, meta));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/8
         *
         * @tapVersion(">=1.73")
         * @param variableId input
         * @param meta input
         * @return call options
         */
        VariableService.prototype.putRawMetaCall = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * Variable meta
         */
        meta) {
            var callOptions = __assign$1({}, this.resources.putRawMeta);
            callOptions.body = meta;
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Get variable meta
         *
         * LWM2M path: /1029/{variableId}/8
         *
         * @tapVersion(">=1.73")
         * @param variableId input
         * @return
         */
        VariableService.prototype.getMeta = function (
        /*
         * ID of the variable
         */
        variableId) {
            return this.serviceCallRunner.execute(this.getMetaCall(variableId));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/8
         *
         * @tapVersion(">=1.73")
         * @param variableId input
         * @return call options
         */
        VariableService.prototype.getMetaCall = function (
        /*
         * ID of the variable
         */
        variableId) {
            var callOptions = __assign$1({}, this.resources.getMeta);
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Write variable meta
         *
         * LWM2M path: /1029/{variableId}/8
         *
         * @tapVersion(">=1.73")
         * @param variableId input
         * @param meta input
         * @return
         */
        VariableService.prototype.putMeta = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * Variable meta
         */
        meta) {
            return this.serviceCallRunner.execute(this.putMetaCall(variableId, meta));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/8
         *
         * @tapVersion(">=1.73")
         * @param variableId input
         * @param meta input
         * @return call options
         */
        VariableService.prototype.putMetaCall = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * Variable meta
         */
        meta) {
            var callOptions = __assign$1({}, this.resources.putMeta);
            callOptions.body = meta;
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Get variable unit
         *
         * LWM2M path: /1029/{variableId}/9
         *
         * @deprecated
         * @tapVersion(">=1.60")
         * @param variableId input
         * @return
         */
        VariableService.prototype.getUnit = function (
        /*
         * Variable id
         */
        variableId) {
            return this.serviceCallRunner.execute(this.getUnitCall(variableId));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/9
         *
         * @deprecated
         * @tapVersion(">=1.60")
         * @param variableId input
         * @return call options
         */
        VariableService.prototype.getUnitCall = function (
        /*
         * Variable id
         */
        variableId) {
            var callOptions = __assign$1({}, this.resources.getUnit);
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Write variable unit
         *
         * LWM2M path: /1029/{variableId}/9
         *
         * @deprecated
         * @tapVersion(">=1.60")
         * @param variableId input
         * @param address input
         * @return
         */
        VariableService.prototype.putUnit = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * Variable unit
         */
        address) {
            return this.serviceCallRunner.execute(this.putUnitCall(variableId, address));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/9
         *
         * @deprecated
         * @tapVersion(">=1.60")
         * @param variableId input
         * @param address input
         * @return call options
         */
        VariableService.prototype.putUnitCall = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * Variable unit
         */
        address) {
            var callOptions = __assign$1({}, this.resources.putUnit);
            callOptions.body = address;
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Get variable array size
         *
         * LWM2M path: /1029/{variableId}/2
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return
         */
        VariableService.prototype.getNumberOfElements = function (
        /*
         * ID of the variable
         */
        variableId) {
            return this.serviceCallRunner.execute(this.getNumberOfElementsCall(variableId));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/2
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return call options
         */
        VariableService.prototype.getNumberOfElementsCall = function (
        /*
         * ID of the variable
         */
        variableId) {
            var callOptions = __assign$1({}, this.resources.getNumberOfElements);
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Write variable array size
         *
         * LWM2M path: /1029/{variableId}/2
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param value input
         * @return
         */
        VariableService.prototype.putNumberOfElements = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * New number of element for this variable
         */
        value) {
            return this.serviceCallRunner.execute(this.putNumberOfElementsCall(variableId, value));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/2
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param value input
         * @return call options
         */
        VariableService.prototype.putNumberOfElementsCall = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         * New number of element for this variable
         */
        value) {
            var callOptions = __assign$1({}, this.resources.putNumberOfElements);
            callOptions.body = value;
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Get access rights for the variable
         *
         * LWM2M path: /1029/{variableId}/3
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return
         */
        VariableService.prototype.getCurrentAccess = function (
        /*
         * ID of the variable
         */
        variableId) {
            return this.serviceCallRunner.execute(this.getCurrentAccessCall(variableId));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/3
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return call options
         */
        VariableService.prototype.getCurrentAccessCall = function (
        /*
         * ID of the variable
         */
        variableId) {
            var callOptions = __assign$1({}, this.resources.getCurrentAccess);
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Get all variable values for the current profile
         *
         * LWM2M path: /1029//4
         *
         * @tapVersion(">=")
         * @return
         */
        VariableService.prototype.readProfile = function () {
            return this.serviceCallRunner.execute(this.readProfileCall());
        };
        /**
         *
         *
         * LWM2M path: /1029//4
         *
         * @tapVersion(">=")
         * @return call options
         */
        VariableService.prototype.readProfileCall = function () {
            var callOptions = __assign$1({}, this.resources.readProfile);
            return callOptions;
        };
        /**
         * Get variable value
         *
         * LWM2M path: /1029/{variableId}/4
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return
         */
        VariableService.prototype.getValue = function (
        /*
         * ID of the variable
         */
        variableId) {
            return this.serviceCallRunner.execute(this.getValueCall(variableId));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/4
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return call options
         */
        VariableService.prototype.getValueCall = function (
        /*
         * ID of the variable
         */
        variableId) {
            var callOptions = __assign$1({}, this.resources.getValue);
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Set variable value
         *
         * LWM2M path: /1029/{variableId}/5
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param value input
         * @return
         */
        VariableService.prototype.setValue = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         *
         */
        value) {
            return this.serviceCallRunner.execute(this.setValueCall(variableId, value));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/5
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param value input
         * @return call options
         */
        VariableService.prototype.setValueCall = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         *
         */
        value) {
            var callOptions = __assign$1({}, this.resources.setValue);
            callOptions.body = value;
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Set variable value
         *
         * LWM2M path: /1029/{variableId}/4
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param value input
         * @return
         */
        VariableService.prototype.putValue = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         *
         */
        value) {
            return this.serviceCallRunner.execute(this.putValueCall(variableId, value));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/4
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param value input
         * @return call options
         */
        VariableService.prototype.putValueCall = function (
        /*
         * ID of the variable
         */
        variableId, 
        /*
         *
         */
        value) {
            var callOptions = __assign$1({}, this.resources.putValue);
            callOptions.body = value;
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Get variable bundle id
         *
         * LWM2M path: /1029/{variableId}/6
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return
         */
        VariableService.prototype.getBundleId = function (
        /*
         *
         */
        variableId) {
            return this.serviceCallRunner.execute(this.getBundleIdCall(variableId));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/6
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return call options
         */
        VariableService.prototype.getBundleIdCall = function (
        /*
         *
         */
        variableId) {
            var callOptions = __assign$1({}, this.resources.getBundleId);
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Write variable bundle id
         *
         * LWM2M path: /1029/{variableId}/6
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param value input
         * @return
         */
        VariableService.prototype.putBundleId = function (
        /*
         *
         */
        variableId, 
        /*
         *
         */
        value) {
            return this.serviceCallRunner.execute(this.putBundleIdCall(variableId, value));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/6
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param value input
         * @return call options
         */
        VariableService.prototype.putBundleIdCall = function (
        /*
         *
         */
        variableId, 
        /*
         *
         */
        value) {
            var callOptions = __assign$1({}, this.resources.putBundleId);
            callOptions.body = value;
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Get variable bundle values (formated as a TLV)
         *
         * LWM2M path: /1029/{variableId}/7
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return
         */
        VariableService.prototype.getBundleValues = function (
        /*
         *
         */
        variableId) {
            return this.serviceCallRunner.execute(this.getBundleValuesCall(variableId));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/7
         *
         * @tapVersion(">=")
         * @param variableId input
         * @return call options
         */
        VariableService.prototype.getBundleValuesCall = function (
        /*
         *
         */
        variableId) {
            var callOptions = __assign$1({}, this.resources.getBundleValues);
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        /**
         * Write variable bundle id
         *
         * LWM2M path: /1029/{variableId}/65535
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param extraSize input
         * @return
         */
        VariableService.prototype.create = function (
        /*
         *
         */
        variableId, 
        /*
         * extra data size in bytes
         */
        extraSize) {
            return this.serviceCallRunner.execute(this.createCall(variableId, extraSize));
        };
        /**
         *
         *
         * LWM2M path: /1029/{variableId}/65535
         *
         * @tapVersion(">=")
         * @param variableId input
         * @param extraSize input
         * @return call options
         */
        VariableService.prototype.createCall = function (
        /*
         *
         */
        variableId, 
        /*
         * extra data size in bytes
         */
        extraSize) {
            var callOptions = __assign$1({}, this.resources.create);
            callOptions.body = extraSize;
            callOptions.pathParameters = {
                variableId: variableId
            };
            return callOptions;
        };
        return VariableService;
    }(tap.AbstractService));

    var __read = (this && this.__read) || function (o, n) {
        var m = typeof Symbol === "function" && o[Symbol.iterator];
        if (!m) return o;
        var i = m.call(o), r, ar = [], e;
        try {
            while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
        }
        catch (error) { e = { error: error }; }
        finally {
            try {
                if (r && !r.done && (m = i["return"])) m.call(i);
            }
            finally { if (e) throw e.error; }
        }
        return ar;
    };
    var utf8Converter = new impl.StringConverter('utf8');
    VariableService.prototype.getMeta = function (id) {
        return this.getRawMeta(id).then(function (response) {
            var metaResponse = response;
            metaResponse.setBodyDecoder({
                decode: function (raw) {
                    var _a = __read(utf8Converter.decode(raw).split(':')), name = _a[0], extra = _a.slice(1);
                    return {
                        name: name,
                        unit: extra.length > 0 ? extra[0] : ''
                    };
                }
            });
            return metaResponse;
        });
    };
    VariableService.prototype.putMeta = function (id, data) {
        var encoded = utf8Converter.encode(data.name + ":" + data.unit);
        return this.putRawMeta(id, encoded);
    };
    VariableService.prototype.getAllValues = function () {
        return this.readProfile().then(function (responseInterface) {
            var response = responseInterface;
            if (response.isSuccessful()) {
                var data = response.rawBody();
                var converter = new impl.TlvBundleConverter();
                var mappings = converter.decode(data);
                response.setBody(mappings);
            }
            return response;
        });
    };

    var VariableMetaConfigConverter = /** @class */ (function () {
        function VariableMetaConfigConverter() {
            this.utf8Converter = new impl.StringConverter('utf8');
        }
        VariableMetaConfigConverter.prototype.encode = function (data) {
            return this.utf8Converter.encode((data.name || '') + ":" + (data.unit || ''));
        };
        VariableMetaConfigConverter.prototype.decode = function (data) {
            var str = this.utf8Converter.decode(data);
            var output = str.split(':');
            return {
                name: output[0],
                unit: output.length >= 2 ? output[1] : ''
            };
        };
        return VariableMetaConfigConverter;
    }());

    var _TAP_SERVICE_EXTENSION_VARIABLE_ = tap.extendServiceContainer("variable", VariableService);

    // Replace generated converter as there is a bug in generated converter (decoding does not split info with character ':')
    var variableMetaConfigConverter = new VariableMetaConfigConverter();
    SERVICE_CALLS.getMeta.responseBodyDecoder = variableMetaConfigConverter;
    SERVICE_CALLS.putMeta.bodyEncoder = variableMetaConfigConverter;

    exports.ModbusVariableAddressConverter = ModbusVariableAddressConverter;
    exports.VARIABLE_SERVICE_CALLS = SERVICE_CALLS;
    exports.VariableMetaConfigConverter = VariableMetaConfigConverter;
    exports.VariableMetaConverter = VariableMetaConverter;
    exports.VariableService = VariableService;
    exports.VariableTypeConverter = VariableTypeConverter;
    exports._TAP_SERVICE_EXTENSION_VARIABLE_ = _TAP_SERVICE_EXTENSION_VARIABLE_;
    exports.variableConverters = serviceConverters;

    Object.defineProperty(exports, '__esModule', { value: true });

})));
//# sourceMappingURL=iotize-tap-service-impl-variable.umd.js.map
