var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Injectable } from '@angular/core';
import { isNil, isNumber } from 'lodash';
import { FCloudDataTypeService } from './fcloud-data-type.service';
import { FBoxDataTypeService } from './fbox-data-type.service';
let DataTypeService = class DataTypeService {
    constructor(fcloudDataTypeService, fboxDataTypeService) {
        this.fcloudDataTypeService = fcloudDataTypeService;
        this.fboxDataTypeService = fboxDataTypeService;
    }
    getValueType(version, id) {
        if (!isNil(version) && version > 4) {
            return this.fcloudDataTypeService.getValueType(id);
        }
        return this.fboxDataTypeService.getValueType(id);
    }
    getValuePattern(version, id) {
        if (!isNil(version) && version > 4) {
            return this.fcloudDataTypeService.getValuePattern(id);
        }
        return this.fboxDataTypeService.getValuePattern(id);
    }
    isHexType(version, id) {
        if (!isNil(version) && version > 4) {
            return this.fcloudDataTypeService.isHexType(id);
        }
        return this.fboxDataTypeService.isHexType(id);
    }
    isBinaryType(version, id) {
        if (!isNil(version) && version > 4) {
            return this.fcloudDataTypeService.isBinaryType(id);
        }
        return this.fboxDataTypeService.isBinaryType(id);
    }
    isHexOrBinaryType(version, id) {
        if (!isNil(version) && version > 4) {
            return this.fcloudDataTypeService.isHexOrBinaryType(id);
        }
        return this.fboxDataTypeService.isHexOrBinaryType(id);
    }
    isFloat(version, id) {
        if (!isNil(version) && version > 4) {
            return this.fcloudDataTypeService.isFloat(id);
        }
        return this.fboxDataTypeService.isFloat(id);
    }
    /**
     * 获取数据型号最大长度
     * @param id fbox数据类型
     */
    getValueMaxLength(version, dataType, fBoxDataType) {
        if (isNumber(fBoxDataType)) {
            return this.fboxDataTypeService.getValueMaxLength(fBoxDataType);
        }
        else {
            if (!isNil(version) && version > 4) {
                return this.fcloudDataTypeService.getValueMaxLength(dataType);
            }
            return this.fboxDataTypeService.getValueMaxLength(dataType);
        }
    }
    /**
     * 是否支持小数位
     * @param version
     * @param id
     */
    isSupportFractionDigit(version, id) {
        if (!isNil(version) && version > 4) {
            return this.fcloudDataTypeService.isSupportFractionDigit(id);
        }
        return this.fboxDataTypeService.isSupportFractionDigit(id);
    }
    /**
     * 是否为有符号数
     * @param version
     * @param id
     */
    isSignedType(version, id) {
        if (!isNil(version) && version > 4) {
            return this.fcloudDataTypeService.isSignedType(id);
        }
        return this.fboxDataTypeService.isSignedType(id);
    }
    /**
     * 是否支持数值运算
     * @param version
     * @param id
     */
    isSupportNumericalOperation(version, id) {
        if (!isNil(version) && version > 4) {
            return this.fcloudDataTypeService.isSupportNumericalOperation(id);
        }
        return this.fboxDataTypeService.isSupportNumericalOperation(id);
    }
    /**
    * 数据转换成10进制
    * @param version
    * @param value
    * @param id
    */
    formatToDecimal(version, value, id) {
        if (!isNil(version) && version > 4) {
            return this.fcloudDataTypeService.formatToDecimal(value, id);
        }
        return this.fboxDataTypeService.formatToDecimal(value, id);
    }
    /**
       * 获取数据型号最小值
       * @param id
       * @param? integerDigits
       * @param? fractionDigits
       */
    getMinValue(version, dataType, fBoxDataType, integerDigits, fractionDigits) {
        if (isNumber(fBoxDataType)) {
            return this.fboxDataTypeService.getMinValue(fBoxDataType, integerDigits, fractionDigits);
        }
        else {
            if (!isNil(version) && version > 4) {
                return this.fcloudDataTypeService.getMinValue(dataType);
            }
            return this.fboxDataTypeService.getMinValue(dataType);
        }
    }
    /**
       * 获取数据型号最大值
       * @param id
       * @param? integerDigits
       * @param? fractionDigits
       */
    getMaxValue(version, dataType, fBoxDataType, integerDigits, fractionDigits) {
        if (isNumber(fBoxDataType)) {
            return this.fboxDataTypeService.getMaxValue(fBoxDataType, integerDigits, fractionDigits);
        }
        else {
            if (!isNil(version) && version > 4) {
                return this.fcloudDataTypeService.getMaxValue(dataType);
            }
            return this.fboxDataTypeService.getMaxValue(dataType);
        }
    }
};
DataTypeService = __decorate([
    Injectable(),
    __metadata("design:paramtypes", [FCloudDataTypeService,
        FBoxDataTypeService])
], DataTypeService);
export { DataTypeService };
