Cancel
Showing results for 
Search instead for 
Did you mean: 

Helpe me with Transporter - train and wagons

Someone can help me with a simulation, it's attached here.

 

  I have two problems this case: the first is in transporter called "trem", my attribute "collisionControl" doesn't work correctly. I intend that "trem" coupling in others transporters called "prancha".

 

is
    i:integer;
    fzg:object;
do    
  
    if self.~.backwards then
        
        fzg:=self.~;
        for i:=1 to self.~.num_pranchas loop
        -- is there a transporter
            if not isVoid(fzg.rearMU) then
                fzg.rearMU.hitchFront;
                fzg:=fzg.rearMU;
            else
                exitloop;
            end;                    
        next;        
                    
        wait(self.~.hookTime);    
        self.~.backwards:=false;
        self.~.stopped:=false;
    end;    
end;

 

The second error is in method of track

 

(SensorID : integer; Bug : boolean)
is
do
    -- let pass the tractor
    if not @.istrem then
        -- in a train only the tractor can stop
        @.gettrem.stopped:=true;
        if sensorID= 1 then
            waituntil load.occupied prio 1;
            load.cont.move(@);
        elseif sensorID =2 then
            waituntil unload.empty prio 1;
            @.cont.move(unload);
        end;
        @.gettrem.stopped:=false;
    end;
end;

 

2 REPLIES

Re: Helpe me with Transporter - train and wagons

Phenom
Phenom

Hi, there were a bunch of changes to get it running (s. attachment)

 

@sensorControl

(SensorID : integer; Bug : boolean)
is
do
 -- let pass the tractor
 if not @.istractor then
  -- in a train only the tractor can stop
  trem.stopped:=true;
  if sensorID= 1 then
   waituntil load.occupied prio 1;
   load.cont.move(@);
  elseif sensorID =2 then
   waituntil unload.empty prio 1;
   @.cont.move(unload);
  end;
  trem.stopped:=false;
 end;
end;

 

 

@CollisonControl

is
	i:integer;
	fzg:object;
do	
	-- if collide backwards --> hook trailer
	-- after hookTime move forewards
	
	fzg:=self.~;
	
	if fzg.backwards then
		
		for i:=1 to fzg.num_pranchas loop
		-- is there a transporter
			if not isVoid(fzg.rearMU) then
				fzg.rearMU.hitchFront;
				--fzg.rearMU.hitchRear;
				fzg:=fzg.rearMU;
			else
				exitloop;
			end;					
		next;		
					
		wait(self.~.hookTime);	
		self.~.backwards:=false;
		self.~.stopped:=false;
	end;	
end;

 

@init

is
	fzg :object;
do
	.MUs.prancha.create(track1, 1.5);
	.MUs.prancha.create(track1, 3.0);
	.MUs.prancha.create(track1, 4.5);	
	trem:=.MUs.trem.create(track1,6.0);
	trem.backwards:=true;
	wait(1.0); -- just in case
end;

 

@pancha class

pancha.isTractor attribut set to false

 

 

 

Re: Helpe me with Transporter - train and wagons

Solution Partner Valued Contributor Solution Partner Valued Contributor
Solution Partner Valued Contributor

Just in case, another way to do it.

 

I almost didn't touch the Onsensor ctrl.

 

Changes in Oncollision and Init.

 

 

cortega@interlatin.com.mx
+52 (81) 10801310
InterLatin S de RL de CV