Showing
1 changed file
with
14 additions
and
7 deletions
| @@ -30,7 +30,9 @@ | @@ -30,7 +30,9 @@ | ||
| 30 | const modBUSForm = ref<any>({}); | 30 | const modBUSForm = ref<any>({}); |
| 31 | const isShowModBUS = ref<Boolean>(false); //用于判断标识符类型是否时自定义还是modBUS | 31 | const isShowModBUS = ref<Boolean>(false); //用于判断标识符类型是否时自定义还是modBUS |
| 32 | const isShowActionType = ref<Boolean>(true); //判断设备属性标识符为modBus时没有填写扩展描述 | 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 | const [register] = useModalInner(async (params: ModalParamsType<DeviceModelOfMatterAttrs>) => { | 37 | const [register] = useModalInner(async (params: ModalParamsType<DeviceModelOfMatterAttrs>) => { |
| 36 | const { record } = params; | 38 | const { record } = params; |
| @@ -39,8 +41,10 @@ | @@ -39,8 +41,10 @@ | ||
| 39 | const { type } = dataType || {}; | 41 | const { type } = dataType || {}; |
| 40 | const { codeType, deviceProfile } = deviceDetail || {}; | 42 | const { codeType, deviceProfile } = deviceDetail || {}; |
| 41 | const { transportType } = deviceProfile || {}; | 43 | const { transportType } = deviceProfile || {}; |
| 42 | - const { registerAddress, actionType } = extensionDesc || {}; | 44 | + const { registerAddress, actionType, zoomFactor } = extensionDesc || {}; |
| 43 | formField.value = identifier; | 45 | formField.value = identifier; |
| 46 | + zoomFactorValue.value = zoomFactor ? Number(zoomFactor) : 1; | ||
| 47 | + isShowMultiply.value = type == 'INT' || type == 'DOUBLE' ? true : false; | ||
| 44 | 48 | ||
| 45 | let schemas = [{ dataType: dataType, identifier, functionName: name } as StructJSON]; | 49 | let schemas = [{ dataType: dataType, identifier, functionName: name } as StructJSON]; |
| 46 | 50 | ||
| @@ -60,7 +64,7 @@ | @@ -60,7 +64,7 @@ | ||
| 60 | modBUSForm.value = { | 64 | modBUSForm.value = { |
| 61 | crc: 'CRC_16_LOWER', | 65 | crc: 'CRC_16_LOWER', |
| 62 | deviceCode: '01', | 66 | deviceCode: '01', |
| 63 | - method: actionType, | 67 | + method: actionType == '16' ? '10' : actionType, |
| 64 | registerAddress, | 68 | registerAddress, |
| 65 | registerNumber: 1, | 69 | registerNumber: 1, |
| 66 | registerValues: [], | 70 | registerValues: [], |
| @@ -102,13 +106,16 @@ | @@ -102,13 +106,16 @@ | ||
| 102 | } | 106 | } |
| 103 | const flag = await validate(); | 107 | const flag = await validate(); |
| 104 | if (!flag) return; | 108 | if (!flag) return; |
| 105 | - | ||
| 106 | const oldValue = getFieldsValue()[unref(formField)]; | 109 | const oldValue = getFieldsValue()[unref(formField)]; |
| 107 | - modBUSForm.value.registerValues = [oldValue]; | 110 | + modBUSForm.value.registerValues = unref(isShowMultiply) |
| 111 | + ? [oldValue * unref(zoomFactorValue)] | ||
| 112 | + : [oldValue]; | ||
| 108 | modBUSForm.value.registerNumber = 1; | 113 | modBUSForm.value.registerNumber = 1; |
| 109 | 114 | ||
| 110 | - if (unref(modBUSForm).method == '16') { | ||
| 111 | - const newValue = getArray(SingleToHex(oldValue)); | 115 | + if (unref(modBUSForm).method == '16' || unref(modBUSForm).method == '10') { |
| 116 | + const newValue = getArray( | ||
| 117 | + SingleToHex(unref(isShowMultiply) ? oldValue * unref(zoomFactorValue) : oldValue) | ||
| 118 | + ); | ||
| 112 | modBUSForm.value.registerValues = newValue; | 119 | modBUSForm.value.registerValues = newValue; |
| 113 | modBUSForm.value.registerNumber = 2; | 120 | modBUSForm.value.registerNumber = 2; |
| 114 | modBUSForm.value.method = '10'; | 121 | modBUSForm.value.method = '10'; |