question

Axel Kohonen avatar image
1 Like"
Axel Kohonen asked Matthew Gillespie commented

What is the best way of getting the input object of a conveyor?

Hi,

How does one access the objects connected upstream of a conveyor? With the previous conveyor library one could use inobject, but how do you do it with then new conveyor library? Inobject from Sink5 gives the exit transfer, but the transfer does not have any input connections defined.

For example: How do you do if you want to get a reference to Queue6 when the item enters Sink5 in the attached image below?

Thank you!

Kind regards,

Axel

FlexSim 16.0.1
conveyorinobject
fueld.png (13.3 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.

1 Answer

·
jing.c avatar image
2 Likes"
jing.c answered Matthew Gillespie commented

Hi,Axel

You can try the code below. It will works even if the object have different upstreams (not only Conveyor Module but also ordinary objects)

treenode ob = node("Sink5", model()); //the upstream object you want to get
int innum = 1; //the input number
treenode inob = inobject(ob,innum);
if(classobject(inob) == node("/conveyor/ExitTransfer",library()))
//Get downstream you can change "ExitTransfer" to "EntryTransfer"
{
	inob = ownerobject(node("/1+",getvarnode(inobject(ob,innum),"transferPoint"))); 
} 
return inob;
· 4
5 |100000

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

Matthew Gillespie avatar image Matthew Gillespie ♦♦ commented ·

Keep in mind that a conveyor can have multiple entry and exit transfers. Conveyors have a conveyorPoints variable that has subnode pointers to all the transfers and decision points/photo eyes on the conveyor.

Here's a way to get at the entry or exit transfers of a conveyor:

treenode points = getvarnode(conveyor, "conveyorPoints");
for(int i = 1; i <= content(points); i++) {
	//The "+" will go to the node pointed at by the coupling data
	//The "~" will get the ownerobject of that node since the
	//pointed at node is in the object's variables
	treenode pointObject = node("+/~", rank(points, i));
	if(isclasstype(pointObject, "Conveyor::EntryTransfer"))
		//This is an entry transfer
	else if(isclasstype(pointObject, "Conveyor::ExitTransfer"))
		//This is an exit transfer
}

3 Likes 3 ·
Axel Kohonen avatar image Axel Kohonen commented ·

Thank you Jing,

It works well although it is harder to use this than the older inobject that worked for all object types. Could you explain what the "/1+" syntax means? /1 is rank 1 right, but what is 1+?

Axel

0 Likes 0 ·
Mischa Spelt avatar image Mischa Spelt Axel Kohonen commented ·
Hi Axel. The + follows the reference in the given node. So node("1/+", x) is equivalent to something like node(getnodestr(node("/1", x))).
2 Likes 2 ·
jing.c avatar image jing.c Axel Kohonen commented ·

Hi Axel, As Mischa said "node("1/+", x) is equivalent to something likenode(getnodestr(node("/1", x)))". And this type of data call Coupling Data, you can use command createcoupling() to connect two nodes. When we use "A" or "S" connection, it will make a coupling with two object in fact.

Cause I am a user not a developer of FlexSim and I'm not major in programming, I can not give you more advice or explain the theory. Maybe someone can tell you more about Coupling Data.

Hope this can help you.

1 Like 1 ·

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.