龙门式装载机
初始化
//生成小车
.MUs.Transporter.create(track,1)
//初始化站加工状态
station1_finished:=false
station2_finished:=false
station3_finished:=false
轨道传感器策略
param SensorID: integer, Front: boolean, BookPos: boolean
var station:object
//小车到达目标位置后执行操作
if @.targetsensor=SensorID
@.stopped:=true
if SensorID=1
//有货就先卸货
if @.occupied
@.cont.move(Drain)
end
waituntil buffer.occupied prio 1
buffer.cont.move(@)
//站加工状态初始化
station1_finished:=false
station2_finished:=false
station3_finished:=false
//寻找站对应的传感器序号
sensorlist.setcursor(1,1)
sensorlist.find(@.cont.Proc_P.read(1))
@.targetsensor:=sensorlist.cursorY
//小车行驶方向改变
@.backwards:=false
else
station:=sensorlist[1,sensorID]
@.cont.move(station)
//如果需要两次在同一站加工,先初始化站状态
str_to_obj(station.name+"_finished"):=false
//等站加工完成
if station=station1
waituntil station1_finished=true prio 1
elseif station=station2
waituntil station2_finished=true prio 1
else
waituntil station3_finished=true prio 1
end
station.cont.move(@)
//零件完成的工步+1
@.cont.Proc_F:=@.cont.Proc_F+1
//零件还有工步未完成,寻找下一目标站位置
if @.cont.Proc_P(@.cont.Proc_F+1) /= void
sensorlist.setcursor(1,1)
sensorlist.find(@.cont.Proc_P.read(@.cont.Proc_F+1))
@.targetsensor:=sensorlist.cursorY
else
@.targetsensor:=1
end
//小车行驶方向由目标与当前位置确定
@.backwards:=(@.targetsensor<sensorID)
end
@.stopped:=false
end
cursor的使用
<Path>.setCursor(Row:integer) → boolean
<Path>.setCursor(Column:any, Row:any) → boolean
setCursor将内部游标设置在Data table或者List的指定单元格
<Path>.find(Value:any) → boolean
<Path>.find([Range:listrange, …,]Value:any) → boolean
find从setCursor设置的位置开始搜索,而且只可用于Array或者Lists,不可用于Data table
CursorX和CursorY可用于设置游标位置或者读取
加工站出口策略
//站加工完成状态更新
str_to_obj(?.name+"_finished"):=true
Drain统计策略
switch @.name
case "Part1"
num_of_part1:=num_of_part1+1
case "Part2"
num_of_part2:=num_of_part2+1
case "Part3"
num_of_part3:=num_of_part3+1
end