Commit c259ba0638381ac4834b5a3ca119595c47e1a71a

Authored by ww
1 parent d52f4118

fix: 修复modbus下发指令错误

... ... @@ -16277,20 +16277,22 @@ class HandleDataInteraction {
16277 16277 number = number.toString()
16278 16278 const floatIndex = number.indexOf('.')
16279 16279 const floatPart = ~floatIndex ? `0.${number.substring(floatIndex + 1)}` : '0';
16280   - return floatPart
  16280 + return Number(floatPart)
16281 16281 }
16282 16282
16283 16283 if (commandType == enumCommandType.MODBUS) {
16284   - value = data[enumActionEl.CUSTOM_TCP_COMMAND]
16285   - const { method, deviceCode, zoomFactor = 1 } = additional || {}
  16284 + value = Number(data[enumActionEl.CUSTOM_TCP_COMMAND])
16286 16285
  16286 + let { method, deviceCode, zoomFactor } = additional || {}
  16287 + zoomFactor = zoomFactor ? zoomFactor : 1
16287 16288 const validate = new Validate([
16288 16289 { value: deviceCode, required: true, message: '未找到设备地址码' },
16289 16290 { value: method, required: true, message: '未找到Modbus命令操作类型' },
  16291 + { value, required: true, message: '下发值不是一个数字', validator(value) { return !isNaN(value) } },
16290 16292 { value, required: true, message: '下发值是必填项' },
16291 16293 ...(method == '05' ? [{ value, message: '下发类型必须为0或1', validator(value) { return value == 0 || value == 1 } }] : []),
16292   - ...(method == '06' ? [{ value, message: `下发类型必须为整型,缩放因子为${zoomFactor}`, validator(value) { return !isNaN(value) && getNumberFloatPart(value) * zoomFactor % 1 === 0 } }, { value: value * zoomFactor, message: `最大值不能超过65535,缩放因子为${zoomFactor}`, validator(value) { return Number(value) <= parseInt('ffff', 16) } }] : []),
16293   - ...(method == '16' ? [{ value, message: '下发类型精确到两位小数', validator(value) { return /^-?\d+(\.\d{0,2})?$/.test( Math.floor(value) * zoomFactor + getNumberFloatPart(value) * zoomFactor) } }] : [])
  16294 + ...(method == '06' ? [{ value, message: `下发类型必须为整型,缩放因子为${zoomFactor}`, validator(value) { return !isNaN(value) && getNumberFloatPart(value) * zoomFactor % 1 === 0 } }, { value: Number(value) * zoomFactor, message: `最大值不能超过65535,缩放因子为${zoomFactor}`, validator(value) { return Number(value) <= parseInt('ffff', 16) } }] : []),
  16295 + ...(method == '16' ? [{ value, message: '下发类型精确到两位小数', validator(value) { return /^-?\d+(\.\d{0,2})?$/.test(Math.floor(Number(value)) * zoomFactor + getNumberFloatPart(Number(value)) * zoomFactor) } }] : [])
16294 16296 ])
16295 16297
16296 16298 if (method == '06' || method == '16') {
... ... @@ -16780,7 +16782,6 @@ class HandleDynamicEffect {
16780 16782 } else if (condition.type === HandleDynamicEffect.enumDisplayType.HIDDEN) {
16781 16783 isShow = false
16782 16784 }
16783   - console.log(condition)
16784 16785 const updateFn = () => {
16785 16786 if (!isShow) {
16786 16787 Object.keys(HandleDynamicEffect.enumActType).forEach(key => {
... ... @@ -16795,9 +16796,7 @@ class HandleDynamicEffect {
16795 16796 }
16796 16797 if (condition.title) {
16797 16798 node.setAttribute('label', condition.title)
16798   - console.log(node)
16799 16799 }
16800   - node.setVisible(isShow)
16801 16800 }
16802 16801 this.insertOnceUpdateFn(node, updateFn)
16803 16802 }
... ...