Commit 234286b2b96ed7769741a15d5625cacb914837c3

Authored by ww
1 parent 48b6727e

fix: 修复开关组件无法下发modbus指令

... ... @@ -16193,9 +16193,15 @@ class HandleDataInteraction {
16193 16193 }
16194 16194 } else {
16195 16195 const { additional = {} } = dataSource
16196   - const { deviceCode, registerAddress } = additional || {}
  16196 + const { deviceCode, registerAddress, method } = additional || {}
16197 16197 if (!deviceCode) UseLayUi.topErrorMsg('未找到设备地址码')
16198 16198 if (!registerAddress) UseLayUi.topErrorMsg('未找到寄存器地址')
  16199 + flag = true
  16200 + value = currentNode.getAttribute(SWITCH_SEND_VALUE)
  16201 + if (method == '16') {
  16202 + const hexValue = UseLayUi.numberToHex(value).split(' ').join('')
  16203 + value = [parseInt(hexValue.slice(0, 4), 16), parseInt(hexValue.slice(4, 8), 16)]
  16204 + }
16199 16205 }
16200 16206
16201 16207 return { flag, value }
... ... @@ -16203,11 +16209,15 @@ class HandleDataInteraction {
16203 16209
16204 16210 function handleSwitchComponent() {
16205 16211 const state = currentNode.getAttribute(SWITCH_STATE)
  16212 +
16206 16213 if (state === SWITCH_STATE_NONE) {
  16214 + UseLayUi.topErrorMsg('暂无数据上报,无法下发指令')
16207 16215 return
16208 16216 }
16209   - const { flag, value } = validateSwitchCommand()
16210 16217
  16218 +
  16219 + const { flag, value } = validateSwitchCommand()
  16220 + console.log({ flag, value })
16211 16221 if (!flag) return
16212 16222
16213 16223 layer.confirm('是否确认下发命令?', async function (index) {
... ...