add: 增加堆垛机驱动选择策略,优化堆垛机和输送机驱动

This commit is contained in:
yanps
2023-11-24 17:00:43 +08:00
parent 28c02b328c
commit c7ed465eab
10 changed files with 254 additions and 68 deletions

View File

@@ -10,7 +10,6 @@ export function updateConfig(plans, deviceCode, id) {
data,
method: 'post'
})
}
export function selectById(id) {
@@ -20,3 +19,11 @@ export function selectById(id) {
})
}
export function findDeviceStrategyOption() {
return request({
url: '/api/customPolicy/getStrategy',
method: 'get'
})
}
export default { findDeviceStrategyOption }

View File

@@ -63,7 +63,7 @@
<div slot="header" class="clearfix">
<span class="role-span">指令相关</span>
</div>
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<!-- <el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="8">
<el-form-item label="检验有货">
@@ -143,6 +143,44 @@
</el-form-item>
</el-col>
</el-row>
</el-form> -->
<el-form ref="form" :inline="true" :model="form" :rules="rules" size="small" label-width="78px">
<el-row>
<el-col :span="12">
<el-form-item label="排:" label-width="150px" prop="x">
<el-input v-model.number="form.x" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="列:" label-width="150px" prop="z">
<el-input v-model.number="form.z" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="层:" label-width="150px" prop="yY">
<el-input v-model.number="form.y" />
</el-form-item>
</el-col>
<!-- <el-col :span="12">
<el-form-item label="最小列:" label-width="150px" prop="minY">
<el-input v-model.number="form.minY" />
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="最大层:" label-width="150px" prop="maxZ">
<el-input v-model.number="form.maxZ" />
</el-form-item>
</el-col> -->
<!-- <el-col :span="12">
<el-form-item label="最小层:" label-width="150px" prop="minZ">
<el-input v-model.number="form.minZ" />
</el-form-item>
</el-col> -->
</el-row>
</el-form>
</el-card>
@@ -324,7 +362,10 @@ export default {
// 从父表单获取设备编码
this.device_id = this.$props.parentForm.device_id
this.device_code = this.$props.parentForm.device_code
queryDriverConfig(this.device_id, this.$props.parentForm.driver_code).then(data => {
queryDriverConfig(
this.device_id,
this.$props.parentForm.driver_code
).then((data) => {
// 给表单赋值,并且属性不能为空
if (data.form) {
const arr = Object.keys(data.form)
@@ -347,15 +388,15 @@ export default {
this.data2 = data.ws
this.sliceItem()
})
selectPlcList().then(data => {
selectPlcList().then((data) => {
this.dataOpcPlcs = data
this.plc_id = this.$props.parentForm.opc_plc_id
})
selectOpcList().then(data => {
selectOpcList().then((data) => {
this.dataOpcservers = data
this.opc_id = this.$props.parentForm.opc_server_id
})
deviceCrud.selectDeviceList().then(data => {
deviceCrud.selectDeviceList().then((data) => {
this.deviceList = data
})
})
@@ -377,19 +418,36 @@ export default {
}
for (const val in this.data1) {
if (this.data1[val].code.indexOf('mode') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 0)
this.data1[val].db =
beforeStr +
'.' +
afterStr.substring(0, 1) +
(parseInt(endNumber) + 0)
}
if (this.data1[val].code.indexOf('move') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 1)
this.data1[val].db =
beforeStr +
'.' +
afterStr.substring(0, 1) +
(parseInt(endNumber) + 1)
}
if (this.data1[val].code.indexOf('carrier_direction') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
this.data1[val].db =
beforeStr +
'.' +
afterStr.substring(0, 1) +
(parseInt(endNumber) + 2)
}
if (this.data1[val].code.indexOf('error') !== -1) {
this.data1[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 4)
this.data1[val].db =
beforeStr +
'.' +
afterStr.substring(0, 1) +
(parseInt(endNumber) + 4)
}
if (this.data1[val].code.indexOf('task') !== -1) {
this.data1[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 8)
this.data1[val].db =
beforeStr + '.' + 'D' + (parseInt(endNumber) + 8)
}
}
}
@@ -411,40 +469,69 @@ export default {
console.log(endNumber)
for (const val in this.data2) {
if (this.data2[val].code.indexOf('to_command') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 0)
this.data2[val].db =
beforeStr +
'.' +
afterStr.substring(0, 1) +
(parseInt(endNumber) + 0)
}
if (this.data2[val].code.indexOf('to_target') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 2)
this.data2[val].db =
beforeStr +
'.' +
afterStr.substring(0, 1) +
(parseInt(endNumber) + 2)
}
if (this.data2[val].code.indexOf('to_container_type') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 4)
this.data2[val].db =
beforeStr +
'.' +
afterStr.substring(0, 1) +
(parseInt(endNumber) + 4)
}
if (this.data2[val].code.indexOf('to_task') !== -1) {
this.data2[val].db = beforeStr + '.' + 'D' + (parseInt(endNumber) + 6)
this.data2[val].db =
beforeStr + '.' + 'D' + (parseInt(endNumber) + 6)
}
if (this.data2[val].code.indexOf('to_strap_times') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 10)
this.data2[val].db =
beforeStr +
'.' +
afterStr.substring(0, 1) +
(parseInt(endNumber) + 10)
}
if (this.data2[val].code.indexOf('to_length') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 12)
this.data2[val].db =
beforeStr +
'.' +
afterStr.substring(0, 1) +
(parseInt(endNumber) + 12)
}
if (this.data2[val].code.indexOf('to_weight') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 14)
this.data2[val].db =
beforeStr +
'.' +
afterStr.substring(0, 1) +
(parseInt(endNumber) + 14)
}
if (this.data2[val].code.indexOf('to_height') !== -1) {
this.data2[val].db = beforeStr + '.' + afterStr.substring(0, 1) + (parseInt(endNumber) + 16)
this.data2[val].db =
beforeStr +
'.' +
afterStr.substring(0, 1) +
(parseInt(endNumber) + 16)
}
}
}
},
changeOpc(val) {
this.dataOpcservers.forEach(item => {
this.dataOpcservers.forEach((item) => {
if (item.opc_id === val) {
this.opc_code = item.opc_code
}
})
selectListByOpcID(val).then(data => {
selectListByOpcID(val).then((data) => {
this.dataOpcPlcs = data
this.plc_id = ''
this.plc_code = ''
@@ -456,7 +543,7 @@ export default {
})
},
changePlc(val) {
this.dataOpcPlcs.forEach(item => {
this.dataOpcPlcs.forEach((item) => {
if (item.plc_id === val) {
this.plc_code = item.plc_code
this.sliceItem()
@@ -465,29 +552,35 @@ export default {
})
},
test_read1() {
testRead(this.data1, this.opc_id).then(data => {
this.data1 = data
console.log(this.data1)
this.notify('操作成功!', 'success')
}).catch(err => {
console.log(err.response.data.message)
})
testRead(this.data1, this.opc_id)
.then((data) => {
this.data1 = data
console.log(this.data1)
this.notify('操作成功!', 'success')
})
.catch((err) => {
console.log(err.response.data.message)
})
},
test_write1() {
testwrite(this.data2, this.opc_id).then(data => {
this.notify('操作成功!', 'success')
}).catch(err => {
console.log(err.response.data.message)
})
testwrite(this.data2, this.opc_id)
.then((data) => {
this.notify('操作成功!', 'success')
})
.catch((err) => {
console.log(err.response.data.message)
})
},
test_read2() {
testRead(this.data2, this.opc_id).then(data => {
this.data2 = data
console.log(this.data2)
this.notify('操作成功!', 'success')
}).catch(err => {
console.log(err.response.data.message)
})
testRead(this.data2, this.opc_id)
.then((data) => {
this.data2 = data
console.log(this.data2)
this.notify('操作成功!', 'success')
})
.catch((err) => {
console.log(err.response.data.message)
})
},
doSubmit() {
this.$refs['form'].validate((valid) => {
@@ -498,35 +591,66 @@ export default {
parentForm.is_route = true
parentForm.plc_id = this.plc_id
parentForm.opc_id = this.opc_id
updateConfig(parentForm, this.form, this.data1, this.data2).then(res => {
this.notify('保存成功', 'success')
this.configLoading = false
}).catch(err => {
this.configLoading = false
console.log(err.response.data.message)
})
updateConfig(parentForm, this.form, this.data1, this.data2)
.then((res) => {
this.notify('保存成功', 'success')
this.configLoading = false
})
.catch((err) => {
this.configLoading = false
console.log(err.response.data.message)
})
}
})
},
sliceItem() { // 拼接DB的Item值
this.data1.forEach(item => {
sliceItem() {
// 拼接DB的Item值
this.data1.forEach((item) => {
const str = item.code
// 是否包含.
if (str.search('.') !== -1) {
// 截取最后一位
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
item.code =
this.opc_code +
'.' +
this.plc_code +
'.' +
this.device_code +
'.' +
str.slice(str.lastIndexOf('.') + 1)
} else {
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
item.code =
this.opc_code +
'.' +
this.plc_code +
'.' +
this.device_code +
'.' +
item.code
}
})
this.data2.forEach(item => {
this.data2.forEach((item) => {
const str = item.code
// 是否包含.
if (str.search('.') !== -1) {
// 截取最后一位
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + str.slice(str.lastIndexOf('.') + 1)
item.code =
this.opc_code +
'.' +
this.plc_code +
'.' +
this.device_code +
'.' +
str.slice(str.lastIndexOf('.') + 1)
} else {
item.code = this.opc_code + '.' + this.plc_code + '.' + this.device_code + '.' + item.code
item.code =
this.opc_code +
'.' +
this.plc_code +
'.' +
this.device_code +
'.' +
item.code
}
})
}
@@ -535,5 +659,4 @@ export default {
</script>
<style scoped>
</style>

View File

@@ -87,8 +87,12 @@
multiple
placeholder="请选择"
>
<el-option :label="'默认'" :value="'value1'" />
<el-option :label="'自定义'" :value="'value2'" />
<el-option
v-for=" option in options"
:key="option.code"
:label="option.name"
:value="option.name"
/>
</el-select>
</el-form-item>
</el-col>
@@ -271,6 +275,7 @@ import { selectListByOpcID } from '@/api/acs/device/opcPlc'
import crud from '@/mixins/crud'
import deviceCrud from '@/api/acs/device/device'
import { findDeviceStrategyOption } from '@/api/acs/device/customPolicyType'
export default {
name: 'OvenGantryManipulator',
@@ -294,6 +299,7 @@ export default {
dataOpcservers: [],
dataOpcPlcs: [],
deviceList: [],
options: [],
data1: [],
data2: [],
form: {
@@ -354,6 +360,12 @@ export default {
deviceCrud.selectDeviceList().then((data) => {
this.deviceList = data
})
console.log('---------------')
findDeviceStrategyOption().then((data) => {
console.log(data)
this.options = data
})
console.log('-----eeeeeeeeeeee----------')
})
},
methods: {