Commit 7680be6810c6aa5561c58df2f95240b4b3b7bd57

Authored by ww
1 parent 668ecba7

fix: 修复bool类型 TCP Modbus设备物模型命令下发&&看板命令

1 1 import { useParseOriginalDataType } from './useParseOriginalDataType';
2 2 import { OriginalDataTypeEnum } from '/@/enums/objectModelEnum';
3 3
  4 +export function getBoolValueByStatus(status: boolean) {
  5 + return status ? parseInt('FF00', 16) : parseInt('0000', 16);
  6 +}
  7 +
4 8 export function useBaseConversion() {
5 9 function DecTo32Float(number: number) {
6 10 const arr = new Uint8Array(4);
... ... @@ -146,7 +150,7 @@ export function useBaseConversion() {
146 150 let result: number[];
147 151
148 152 if (type === OriginalDataTypeEnum.BOOLEAN) {
149   - result = [value];
  153 + result = [getBoolValueByStatus(!!value)];
150 154 } else if (type === OriginalDataTypeEnum.STRING) {
151 155 let buffer = StringToHEXBuffer(value);
152 156 const { registerNumber = 0 } = additional || {};
... ...
... ... @@ -14,7 +14,7 @@ import {
14 14 TransportTypeEnum,
15 15 } from '/@/enums/deviceEnum';
16 16 import { FunctionTypeEnum } from '/@/enums/objectModelEnum';
17   -import { isFunction } from '/@/utils/is';
  17 +import { isFunction, isNullOrUnDef } from '/@/utils/is';
18 18 import { getDeviceActiveTime } from '/@/api/alarm/position';
19 19 import { useMessage } from '../web/useMessage';
20 20
... ... @@ -152,7 +152,7 @@ export function useCommandDelivery() {
152 152 rpcCommand,
153 153 setupResult
154 154 );
155   - rpcCommand = _rpcCommand;
  155 + !isNullOrUnDef(rpcCommand) && (rpcCommand = _rpcCommand);
156 156 if (_way) way = _way;
157 157 }
158 158
... ...
... ... @@ -135,6 +135,26 @@ export const useGenerateFormSchemasByObjectModel = () => {
135 135 const { valueRange } = specs as Specs;
136 136 const { max, min } = valueRange || {};
137 137
  138 + if (extensionDesc?.originalDataType === OriginalDataTypeEnum.BOOLEAN) {
  139 + const options = [
  140 + { label: '闭合', value: parseInt('FF00', 16) },
  141 + { label: '断开', value: parseInt('0000', 16) },
  142 + ];
  143 +
  144 + return {
  145 + field: identifier,
  146 + label: name,
  147 + component: 'Select',
  148 + componentProps: () => {
  149 + return {
  150 + options,
  151 + placeholder: `请选择${name}`,
  152 + getPopupContainer: () => document.body,
  153 + };
  154 + },
  155 + };
  156 + }
  157 +
138 158 const isStringType = extensionDesc?.originalDataType === OriginalDataTypeEnum.STRING;
139 159 return {
140 160 field: identifier,
... ...