const settings = {
type: 'object',
title: '驱动配置',
properties: {
ip: {
type: 'string',
format: 'ipv4',
title: '设备IP',
fieldType: 'ip',
},
port: {
type: 'number',
title: '端口'
},
timeout: {
type: 'number',
title: '连接超时时间 (s)',
description: '默认为10s'
},
}
}
const device = {
type: 'object',
properties: {
ip: {
type: 'string',
format: 'ipv4',
title: '设备IP',
fieldType: 'ip',
},
port: {
type: 'number',
title: '端口'
},
unit: {
type: 'number',
title: '站号'
},
},
}
const tags = {
title: '数据点',
type: 'array',
items: {
type: 'object',
properties: {
name: {
type: 'string',
title: '名称'
},
id: {
type: 'string',
title: '标识'
},
offset: {
type: 'number',
title: '偏移地址'
},
},
required: ['name', 'id', 'offset'],
form: ['*']
}
}
const commands = {
title: '指令',
type: 'array',
items: {
type: 'object',
properties: {
name: {
type: 'string',
title: '名称'
},
form,
ops: {
type: 'array',
title: '指令',
items: {
type: 'object',
properties: {
offset: {
type: 'number',
title: '偏移地址'
},
index: {
type: 'number',
title: '下标',
description: '适用于寄存器区控制多开关情况'
},
value: {
type: 'string',
title: '默认写入值'
},
single: {
type: 'boolean',
title: '单字节'
}
}
}
}
}
}
}
export default app.use({
name: 'iot.custom_driver',
drivers:{
cutomDriver:{
title: '自定义XXX协议',
key: 'cutomDriverName',
table: {
properties: {
settings,
tags,
commands
}
},
device: {
properties: {
settings:device,
tags,
commands
}
}
}
}
})