question

Manuel Sinco avatar image
0 Likes"
Manuel Sinco asked Santiago Serrano commented

How to calculate the distance between 2 Objects in a conveyor?

I want to calculate the distance between two object in the conveyor, I planned to used the normal distances formula, however it's only for straight paths, if I have any curved conveyors it won't work.

I'm attaching a image to give an example.

I appreciate your help thanks.

FlexSim 18.2.3
distance along conveyor
distance.png (241.9 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Joshua S avatar image
0 Likes"
Joshua S answered Joshua S commented

For the item on the Conveyor, you can select it and find out how far along on the Conveyor it is in the quick properties, then for each conveyor you can find out its length by opening a script window and use this code

model.find("Conveyor").as(Conveyor).length
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Manuel Sinco avatar image Manuel Sinco commented ·

I know about the quick properties and understand what you are saying, but I have a lot of DP in my conveyor I want to develop a code that can tell me that automatically de distance between them.

That works only with 1 conveyor, so I need to know how many conveyors are joint together. For example in the photo that I'm showing I have 4 connected conveyors so it'll be, only for this case:


double Distance = model.find("Conveyor1").as(Conveyor).length + model.find("Conveyor2").as(Conveyor).length + model.find("Conveyor3").as(Conveyor).length + model.find("Conveyor4").as(Conveyor).length;

And then I need to know where DP 1 & 2 are and then take way that distance.

I want something that when I indicate where are those DP I would knoe the distance in the conveyor between them, independently of where they are.

0 Likes 0 ·
Joshua S avatar image Joshua S Manuel Sinco commented ·

See if this code works for you. For setup, create a group named "ConveyorSystem1", then add the conveyors to the group in path/input order. I added a sample model to demonstrate this.

Object DP1=Model.find("DP1");//First Decision Point, must be behind the second Decision Point
Object DP2=Model.find("DP2");//Second Decision Point, must be ahead of the first Decision Point
Object CDP1=ownerobject(getvarnode(DP1, "conveyorPoint").subnodes[1].value);
Object CDP2=ownerobject(getvarnode(DP2, "conveyorPoint").subnodes[1].value);
double Dist=0;
for (int i=1;i<=getvarnode(CDP1, "conveyorPoints").subnodes.length;i++)
{
	if (ownerobject(getvarnode(CDP1, "conveyorPoints").subnodes[i].value)==DP1)
	{
		Dist+=getvarnum(CDP1, "length")-getvarnode(CDP1, "conveyorPoints").subnodes[i].subnodes[1].value;
	}
}


for (int i=1;i<=getvarnode(CDP2, "conveyorPoints").subnodes.length;i++)
{
	if (ownerobject(getvarnode(CDP2, "conveyorPoints").subnodes[i].value)==DP2)
	{
		Dist+=getvarnode(CDP2, "conveyorPoints").subnodes[i].subnodes[1].value;
	}
}
for (int i=Group("ConveyorSystem1").indexOf(CDP1)+1;i < Group("ConveyorSystem1").indexOf(CDP2);i++ )
{
	Dist+=getvarnum(Group("ConveyorSystem1")[i], "length");
}
return Dist;

dist-on-conveyor.fsm

0 Likes 0 ·
Santiago Serrano avatar image
1 Like"
Santiago Serrano answered Santiago Serrano commented

Hi,

Other way to calculate that, using the decision point is the property of Conveyor Class:

Conveyor.estimateConveyTime()

Arguments: estimateConveyTime( Object origin , double n_a , Object dest , double n_a , double itemLength , int flags = 0 )

this property return the time between two decision point, using default speed

Distance= Conveyor.defaultSpeed * Conveyor.estimateConveyTime( D1, 0 , D2, 1,0)

Where

D1: Decision poitn 1

D2: Decision poitn 2

Item leght: use 1

The manual says use "0" for " n_a"

· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Manuel Sinco avatar image Manuel Sinco commented ·

Funcionó exactamente cómo estaba buscando, muchas gracias @Santiago Serrano. Saludos!

1 Like 1 ·
Santiago Serrano avatar image Santiago Serrano Manuel Sinco commented ·

Que bueno

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.