增加设备节点当前值获取HslServer的设备节点值功能

This commit is contained in:
wu
2022-08-21 13:00:46 +08:00
parent c4f38267e9
commit 74fcfc16f5
2 changed files with 21 additions and 8 deletions

View File

@@ -93,5 +93,14 @@ export default ({ service, request, serviceForMock, requestForMock, mock, faker,
},
url: url + '/Edge/DeviceData?data=__status'
})
},
GET_DEVICE_POINT_VALUE(url, username, password, deviceName){
return request({
auth: {
username: username,
password: password
},
url: url + '/Edge/BrowseDeviceDataNodes?data=' + deviceName
})
}
})

View File

@@ -401,6 +401,7 @@ export default {
},
async getDeviceConfigure (e) {
this.deviceActiveStatus = e
const devicePointValue = this.getDevicePoint()
this.devicePointData = [] // 当切换设备时把保存configure、point的数据清空
this.defaultDeviceName = ''
const deviceData = await this.$api.GET_DEVICE_CONFIGURE(this.deviceData[e].id)
@@ -413,15 +414,16 @@ export default {
}
// 获取point信息
if (conf.RequestNode !== undefined && conf.RequestNode.length > 0) {
this.devicePointData = each(conf.RequestNode, (o, i) => (
this.devicePointData = each(conf.RequestNode, (o, i) => {
assign(o, {
id: i + 1,
showBindButton: true,
showSendButton: true,
showCopyButton: true,
showRemoveButton: true
showRemoveButton: true,
"@Value": devicePointValue[o['@Name']]
})
))
})
}
}
},
@@ -486,15 +488,18 @@ export default {
}
this.formOptions.saveLoading = false
},
async delDevicePoint ({ index, row }, done) {
this.$delete(this.devicePointData, index)
done()
},
async getDevicePoint () {
const data = { action: 'add_node', server_id: this.serverData.id, device_id: this.deviceData[this.deviceActiveStatus].id }
try {
this.devicePointData = await this.$api.GET_DEVICE_POINT(data)
let data = {}
const devicePointValue = await this.$api.GET_DEVICE_POINT_VALUE('http://' + this.serverData.url + ':' + this.serverData.port, 'admin', process.env.VUE_APP_HSLSERVER_PASSWORD, this.deviceData[this.deviceActiveStatus].name)
each(devicePointValue.Content, o=>{
data[o.Name] = o.value || ''
})
return data
} catch (e) {
console.log(e)
}
@@ -564,7 +569,6 @@ export default {
console.log(e)
}
},
async getDeviceStatus () {
const res = await this.$api.GET_SERVER_DEVICE_STATUS('http://' + this.serverData.url + ':' + this.serverData.port, 'admin', process.env.VUE_APP_HSLSERVER_PASSWORD)
if (res) {
@@ -584,7 +588,7 @@ export default {
} else {
this.$emit('changeStatus', false)
}
}
},
},
mounted () {
this.getDevice()