[Plant Simulation]使用Tractor功能的Transportor(与Tractor相关的函数使用)

Tractor的使用

在这里插入图片描述

初始化

--小车长度为1.6
.MUs.Transporter.create(track,1.6)
.MUs.Transporter.create(track,3.2)
.MUs.Transporter.create(track,4.8)
.MUs.Tractor.create(track1,3)

Tractor碰撞控制策略

通过碰撞控制使火车一节一节地挂到牵引车上

var i:integer
var obj:object
--第一个拖车时用
if ?.backwards
	obj:=?
	for i:=1 to num_trailer
		if obj.rearMU /= void
			obj.rearMU.hitchFront
			obj:=obj.rearMU
		else
			--拉到指定数量的车退出循环
			exitloop
		end
	next
	wait hook_time
	?.backwards:=false
	?.stopped:=false
end

collision control

对于拖车来说,碰撞时,牵引车的collision control总是被触发,在方法中,@是实际发生碰撞的Transporter,?是拖车的牵引车Tractor

hitchFront

<MU-Path-Transporter-rear>.hitchFront

在这里插入图片描述

hitchFront将车挂到对象的前侧,牵引车Tractor的速度和方向将复制到拖车的挂车上,active Transporter可以是拖车,牵引车或者未属于拖车的运输车之一

挂起两列都带有Tractor的拖车时,挂起拖车的IsTractor属性将要失效

-- @ is the transporter which Collided
-- @.frontMu references the transporter in front
-- hitch the current transporter to the transporter driving in front of it
@.hitchFront

类似的函数还有UnhitchFronthitchRearUnhitchRear

Track传感器策略

param SensorID: integer, Front: boolean, BookPos: boolean
--车头不装货
if not @.isTractor
	--只有车头可以停
	@.getTractor.stopped:=true
	if sensorID=1
		waituntil (S1.occupied and S1.Proc_F) prio 1
		S1.cont.move(@)
		S1.Proc_F:=false
	elseif sensorID=2
		waituntil S2.empty prio 1
		@.cont.move(S2)
		S2.Proc_F:=false
	end
	--车头move
	@.getTractor.stopped:=false
end

IsTractor

<MU-Path>.IsTractor:boolean

为了防止Tractor装载货物,将XDim和YDim输为0或者将Capacity输为0

GetTractor

<MU-Path>.GetTractor → object

只读属性GetTractor返回牵引车,运动与否需要控制牵引车的stopped

GetFrontWagon返回挂在active Transporter前端的Transporter
GetRearWagon返回挂在active Transporter后端的Transporter

下载链接

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值