Commit d0a8e2b5a37f22f4e55dd40c1205faa8fab7b19c
Merge branch 'fix/object-model-bool' into 'main_dev'
fix: 修复bool类型TCP Modbus设备命令值 See merge request yunteng/thingskit-scada!217
Showing
2 changed files
with
25 additions
and
1 deletions
| ... | ... | @@ -53,6 +53,26 @@ export const createModbusValueInput = (objectModel: Tsl): FormSchema => { |
| 53 | 53 | const { valueRange } = specs as Specs |
| 54 | 54 | const { max, min } = valueRange || {} |
| 55 | 55 | |
| 56 | + if (extensionDesc?.originalDataType === OriginalDataTypeEnum.BOOLEAN) { | |
| 57 | + const options = [ | |
| 58 | + { label: '闭合', value: parseInt('FF00', 16) }, | |
| 59 | + { label: '断开', value: parseInt('0000', 16) }, | |
| 60 | + ] | |
| 61 | + | |
| 62 | + return { | |
| 63 | + field: identifier, | |
| 64 | + label: functionName, | |
| 65 | + component: ComponentEnum.SELECT, | |
| 66 | + componentProps: () => { | |
| 67 | + return { | |
| 68 | + options, | |
| 69 | + placeholder: `请选择${functionName}`, | |
| 70 | + getPopupContainer: () => document.body, | |
| 71 | + } | |
| 72 | + }, | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 56 | 76 | const isStringType = extensionDesc?.originalDataType === OriginalDataTypeEnum.STRING |
| 57 | 77 | return { |
| 58 | 78 | field: identifier, | ... | ... |
| 1 | 1 | import { OriginalDataTypeEnum } from '@/enums/objectModelEnum' |
| 2 | 2 | import { useParseOriginalDataType } from '@/hooks/business/useParseOriginalDataType' |
| 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) |
| ... | ... | @@ -143,7 +147,7 @@ export function useBaseConversion() { |
| 143 | 147 | let result: number[] |
| 144 | 148 | |
| 145 | 149 | if (type === OriginalDataTypeEnum.BOOLEAN) { |
| 146 | - result = [value] | |
| 150 | + result = [getBoolValueByStatus(!!value)] | |
| 147 | 151 | } |
| 148 | 152 | else if (type === OriginalDataTypeEnum.BITS) { |
| 149 | 153 | const { bitMask = 0 } = additional || {} | ... | ... |