Showing
1 changed file
with
14 additions
and
7 deletions
| ... | ... | @@ -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,10 @@ | 
| 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 || {}; | |
| 43 | 45 | formField.value = identifier; | 
| 46 | + zoomFactorValue.value = zoomFactor ? Number(zoomFactor) : 1; | |
| 47 | + isShowMultiply.value = type == 'INT' || type == 'DOUBLE' ? true : false; | |
| 44 | 48 | |
| 45 | 49 | let schemas = [{ dataType: dataType, identifier, functionName: name } as StructJSON]; | 
| 46 | 50 | |
| ... | ... | @@ -60,7 +64,7 @@ | 
| 60 | 64 | modBUSForm.value = { | 
| 61 | 65 | crc: 'CRC_16_LOWER', | 
| 62 | 66 | deviceCode: '01', | 
| 63 | - method: actionType, | |
| 67 | + method: actionType == '16' ? '10' : actionType, | |
| 64 | 68 | registerAddress, | 
| 65 | 69 | registerNumber: 1, | 
| 66 | 70 | registerValues: [], | 
| ... | ... | @@ -102,13 +106,16 @@ | 
| 102 | 106 | } | 
| 103 | 107 | const flag = await validate(); | 
| 104 | 108 | if (!flag) return; | 
| 105 | - | |
| 106 | 109 | const oldValue = getFieldsValue()[unref(formField)]; | 
| 107 | - modBUSForm.value.registerValues = [oldValue]; | |
| 110 | + modBUSForm.value.registerValues = unref(isShowMultiply) | |
| 111 | + ? [oldValue * unref(zoomFactorValue)] | |
| 112 | + : [oldValue]; | |
| 108 | 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 | 119 | modBUSForm.value.registerValues = newValue; | 
| 113 | 120 | modBUSForm.value.registerNumber = 2; | 
| 114 | 121 | modBUSForm.value.method = '10'; | ... | ... |