You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

61 lines
2.1 KiB

const gstore = '108_108'
const agvId = '4'
const demoLocList = ['rack3/0/1/0', 'rack3/1/1/0', 'rack3/0/2/0', 'rack3/1/2/0']
const demoLocList2 = ['rack3/0/1/0', 'rack3/1/1/0', 'rack3/0/2/0', 'rack3/1/2/0'].reverse()
while (true) {
await LCC.sleep(3000)
const [dd] = (await LCC.queryInv({ rack: gstore })).data
if (dd) {
// 地堆上有托盘, 找一个空货位放过去
for (const loc of demoLocList) {
const [rack, bay, level] = loc.split('/')
if (!rack) {
continue;
}
const [emptyLoc] = (await LCC.queryInv({ rack, bay: parseInt(bay), level: parseInt(level) })).data
if (!emptyLoc) {
// 这是一个好位置
LCC.log('agvCarry', gstore, loc)
await RCS.agvCarry(agvId, gstore, loc)
await RCS.waitTaskFinish(agvId)
await LCC.sleep(1000)
break;
}
}
} else {
// 地上没有托盘位, 找个位置拖过去
const [carInv] = (await LCC.queryInv({ rack: agvId, bay: 0, level: 0, cell: 0 })).data
if (carInv) {
LCC.log('托盘在车上')
LCC.log(`RCS.agvUnload('${agvId}', '${gstore}')`)
await RCS.agvUnload(agvId, gstore)
await RCS.waitTaskFinish(agvId)
await LCC.sleep(1000)
continue;
} else {
LCC.log('托盘在货架')
}
let has = false
for (const loc of demoLocList2) {
const [rack, bay, level, cell] = loc.split('/')
const [palletLoc] = (await LCC.queryInv({ rack, bay: parseInt(bay), level: parseInt(level) })).data
if (palletLoc) {
has = true
LCC.log(`RCS.agvCarry('${agvId}', '${loc}', '${gstore}')`)
await RCS.agvCarry(agvId, loc, gstore)
await RCS.waitTaskFinish(agvId)
await LCC.sleep(1000)
break
}
}
if (!has) {
LCC.log('货架没有空托盘,无法执行')
}
}
}