Commit 8a0e6a23893c31af57d81da15bfb6a9526ff3c29

Authored by xp.Huang
2 parents 0c29fac5 2d6f3973

Merge branch 'fix/DEFECT-1475' into 'main_dev'

属性下发时int和double相乘缩放因子

See merge request yunteng/thingskit-front!789
... ... @@ -30,7 +30,9 @@
30 30 const modBUSForm = ref<any>({});
31 31 const isShowModBUS = ref<Boolean>(false); //用于判断标识符类型是否时自定义还是modBUS
32 32 const isShowActionType = ref<Boolean>(true); //判断设备属性标识符为modBus时没有填写扩展描述
33   - const formField = ref('');
  33 + const formField = ref(''); //存一个表单取值的field
  34 + const zoomFactorValue = ref<number>(1); //缩放因子
  35 + const isShowMultiply = ref<Boolean>(false); // 只有tcp --> int和double类型才相乘缩放因子
34 36
35 37 const [register] = useModalInner(async (params: ModalParamsType<DeviceModelOfMatterAttrs>) => {
36 38 const { record } = params;
... ... @@ -39,8 +41,11 @@
39 41 const { type } = dataType || {};
40 42 const { codeType, deviceProfile } = deviceDetail || {};
41 43 const { transportType } = deviceProfile || {};
42   - const { registerAddress, actionType } = extensionDesc || {};
  44 + const { registerAddress, actionType, zoomFactor } = extensionDesc || {}; //获取扩展描述内容
  45 +
43 46 formField.value = identifier;
  47 + zoomFactorValue.value = zoomFactor ? Number(zoomFactor) : 1;
  48 + isShowMultiply.value = type == 'INT' || type == 'DOUBLE' ? true : false;
44 49
45 50 let schemas = [{ dataType: dataType, identifier, functionName: name } as StructJSON];
46 51
... ... @@ -60,7 +65,7 @@
60 65 modBUSForm.value = {
61 66 crc: 'CRC_16_LOWER',
62 67 deviceCode: '01',
63   - method: actionType,
  68 + method: actionType == '16' ? '10' : actionType,
64 69 registerAddress,
65 70 registerNumber: 1,
66 71 registerValues: [],
... ... @@ -104,11 +109,17 @@
104 109 if (!flag) return;
105 110
106 111 const oldValue = getFieldsValue()[unref(formField)];
107   - modBUSForm.value.registerValues = [oldValue];
108 112 modBUSForm.value.registerNumber = 1;
  113 + modBUSForm.value.registerValues = [oldValue];
  114 + if (unref(isShowMultiply) && unref(modBUSForm).method == '06') {
  115 + //bool类型的就不用去乘缩放因子了
  116 + modBUSForm.value.registerValues = [oldValue * unref(zoomFactorValue)];
  117 + }
109 118
110   - if (unref(modBUSForm).method == '16') {
111   - const newValue = getArray(SingleToHex(oldValue));
  119 + if (unref(modBUSForm).method == '16' || unref(modBUSForm).method == '10') {
  120 + const newValue = getArray(
  121 + SingleToHex(unref(isShowMultiply) ? oldValue * unref(zoomFactorValue) : oldValue)
  122 + );
112 123 modBUSForm.value.registerValues = newValue;
113 124 modBUSForm.value.registerNumber = 2;
114 125 modBUSForm.value.method = '10';
... ...