Commit 7680be6810c6aa5561c58df2f95240b4b3b7bd57

Authored by ww
1 parent 668ecba7

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

1 import { useParseOriginalDataType } from './useParseOriginalDataType'; 1 import { useParseOriginalDataType } from './useParseOriginalDataType';
2 import { OriginalDataTypeEnum } from '/@/enums/objectModelEnum'; 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 export function useBaseConversion() { 8 export function useBaseConversion() {
5 function DecTo32Float(number: number) { 9 function DecTo32Float(number: number) {
6 const arr = new Uint8Array(4); 10 const arr = new Uint8Array(4);
@@ -146,7 +150,7 @@ export function useBaseConversion() { @@ -146,7 +150,7 @@ export function useBaseConversion() {
146 let result: number[]; 150 let result: number[];
147 151
148 if (type === OriginalDataTypeEnum.BOOLEAN) { 152 if (type === OriginalDataTypeEnum.BOOLEAN) {
149 - result = [value]; 153 + result = [getBoolValueByStatus(!!value)];
150 } else if (type === OriginalDataTypeEnum.STRING) { 154 } else if (type === OriginalDataTypeEnum.STRING) {
151 let buffer = StringToHEXBuffer(value); 155 let buffer = StringToHEXBuffer(value);
152 const { registerNumber = 0 } = additional || {}; 156 const { registerNumber = 0 } = additional || {};
@@ -14,7 +14,7 @@ import { @@ -14,7 +14,7 @@ import {
14 TransportTypeEnum, 14 TransportTypeEnum,
15 } from '/@/enums/deviceEnum'; 15 } from '/@/enums/deviceEnum';
16 import { FunctionTypeEnum } from '/@/enums/objectModelEnum'; 16 import { FunctionTypeEnum } from '/@/enums/objectModelEnum';
17 -import { isFunction } from '/@/utils/is'; 17 +import { isFunction, isNullOrUnDef } from '/@/utils/is';
18 import { getDeviceActiveTime } from '/@/api/alarm/position'; 18 import { getDeviceActiveTime } from '/@/api/alarm/position';
19 import { useMessage } from '../web/useMessage'; 19 import { useMessage } from '../web/useMessage';
20 20
@@ -152,7 +152,7 @@ export function useCommandDelivery() { @@ -152,7 +152,7 @@ export function useCommandDelivery() {
152 rpcCommand, 152 rpcCommand,
153 setupResult 153 setupResult
154 ); 154 );
155 - rpcCommand = _rpcCommand; 155 + !isNullOrUnDef(rpcCommand) && (rpcCommand = _rpcCommand);
156 if (_way) way = _way; 156 if (_way) way = _way;
157 } 157 }
158 158
@@ -135,6 +135,26 @@ export const useGenerateFormSchemasByObjectModel = () => { @@ -135,6 +135,26 @@ export const useGenerateFormSchemasByObjectModel = () => {
135 const { valueRange } = specs as Specs; 135 const { valueRange } = specs as Specs;
136 const { max, min } = valueRange || {}; 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 const isStringType = extensionDesc?.originalDataType === OriginalDataTypeEnum.STRING; 158 const isStringType = extensionDesc?.originalDataType === OriginalDataTypeEnum.STRING;
139 return { 159 return {
140 field: identifier, 160 field: identifier,