...
|
...
|
@@ -13,6 +13,7 @@ |
13
|
13
|
import { genModbusCommand } from '/@/api/task';
|
14
|
14
|
import { TaskTypeEnum } from '/@/views/task/center/config';
|
15
|
15
|
import { SingleToHex, formSchemasConfig } from './config';
|
|
16
|
+ import { TransportTypeEnum } from '/@/views/device/profiles/components/TransportDescript/const';
|
16
|
17
|
|
17
|
18
|
defineEmits(['register']);
|
18
|
19
|
const props = defineProps<{ deviceId: string; deviceName: string }>();
|
...
|
...
|
@@ -33,6 +34,7 @@ |
33
|
34
|
const formField = ref(''); //存一个表单取值的field
|
34
|
35
|
const zoomFactorValue = ref<number>(1); //缩放因子
|
35
|
36
|
const isShowMultiply = ref<Boolean>(false); // 只有tcp --> int和double类型才相乘缩放因子
|
|
37
|
+ const deviceTransportType = ref<string>();
|
36
|
38
|
|
37
|
39
|
const [register] = useModalInner(async (params: ModalParamsType<DeviceModelOfMatterAttrs>) => {
|
38
|
40
|
const { record } = params;
|
...
|
...
|
@@ -45,6 +47,7 @@ |
45
|
47
|
formField.value = identifier;
|
46
|
48
|
zoomFactorValue.value = zoomFactor ? Number(zoomFactor) : 1;
|
47
|
49
|
isShowMultiply.value = type == 'INT' || type == 'DOUBLE' ? true : false;
|
|
50
|
+ deviceTransportType.value = transportType;
|
48
|
51
|
|
49
|
52
|
let schemas = [{ dataType: dataType, identifier, functionName: name } as StructJSON];
|
50
|
53
|
|
...
|
...
|
@@ -59,7 +62,7 @@ |
59
|
62
|
|
60
|
63
|
//是modBUS类型的就用另外的表单
|
61
|
64
|
//判断是否是TCP ==> modBus的下发命令
|
62
|
|
- if (codeType == TaskTypeEnum.MODBUS_RTU && transportType == 'TCP') {
|
|
65
|
+ if (codeType === TaskTypeEnum.MODBUS_RTU && transportType == TransportTypeEnum.TCP) {
|
63
|
66
|
isShowModBUS.value = true;
|
64
|
67
|
modBUSForm.value = {
|
65
|
68
|
crc: 'CRC_16_LOWER',
|
...
|
...
|
@@ -72,8 +75,31 @@ |
72
|
75
|
setProps({ schemas: formSchemasConfig(schemas[0], actionType) });
|
73
|
76
|
} else {
|
74
|
77
|
isShowModBUS.value = false;
|
75
|
|
- const formSchemas = genForm(schemas);
|
76
|
|
- setProps({ schemas: formSchemas });
|
|
78
|
+ if (transportType === TransportTypeEnum.TCP) {
|
|
79
|
+ setProps({
|
|
80
|
+ schemas: [
|
|
81
|
+ {
|
|
82
|
+ field: 'command',
|
|
83
|
+ label: name,
|
|
84
|
+ component: 'Input',
|
|
85
|
+ required: true,
|
|
86
|
+ rules: [
|
|
87
|
+ {
|
|
88
|
+ pattern: /^[\s0-9a-fA-F]+$/,
|
|
89
|
+ required: true,
|
|
90
|
+ message: '请输入ASCII或HEX服务命令(0~9/A~F)',
|
|
91
|
+ },
|
|
92
|
+ ],
|
|
93
|
+ componentProps: {
|
|
94
|
+ placeholder: `请输入${name}`,
|
|
95
|
+ },
|
|
96
|
+ },
|
|
97
|
+ ],
|
|
98
|
+ });
|
|
99
|
+ } else {
|
|
100
|
+ const formSchemas = genForm(schemas);
|
|
101
|
+ setProps({ schemas: formSchemas });
|
|
102
|
+ }
|
77
|
103
|
}
|
78
|
104
|
|
79
|
105
|
resetFields();
|
...
|
...
|
@@ -164,6 +190,11 @@ |
164
|
190
|
sendValue.value = unref(keys).reduce((prev, next) => {
|
165
|
191
|
return { ...prev, [next]: _value[next] };
|
166
|
192
|
}, {});
|
|
193
|
+
|
|
194
|
+ // tcp 设备下发字符串
|
|
195
|
+ if (unref(deviceTransportType) === TransportTypeEnum.TCP) {
|
|
196
|
+ sendValue.value = Object.values(_value).join('').replaceAll(/\s/g, '');
|
|
197
|
+ }
|
167
|
198
|
}
|
168
|
199
|
|
169
|
200
|
await sendCommandOneway({
|
...
|
...
|
@@ -171,11 +202,7 @@ |
171
|
202
|
value: {
|
172
|
203
|
persistent: true,
|
173
|
204
|
method: 'methodThingskit',
|
174
|
|
- params: unref(isShowModBUS)
|
175
|
|
- ? unref(sendValue)
|
176
|
|
- : {
|
177
|
|
- ...unref(sendValue),
|
178
|
|
- },
|
|
205
|
+ params: unref(sendValue),
|
179
|
206
|
},
|
180
|
207
|
});
|
181
|
208
|
createMessage.success('属性下发成功~');
|
...
|
...
|
|