question

Mischa Spelt avatar image
0 Likes"
Mischa Spelt asked Mischa Spelt commented

Bug: Pull from list trigger option broken!

The Pull From List trigger option seems to be pretty broken. I tried to use it on a Conveyor Decision Point:

Conveyor.DecisionPoint current = param(1);
Object item = param(2);
Conveyor conveyor = param(3);
Conveyor.Item conveyorItem = conveyor.itemData[item];
{ //************* PickOption Start *************\\
/***popup:TriggerPullFromList*/
/***tag:description*//**Pull From List1*/
if (/** \nCondition: *//***tag:condition*//**/true/**/) {
	int callbackCase = param(6);
	#define CALLBACK_CASE 10293
	int numRequired = /** \nRequire: *//***tag:requireNum*//**/1/**/;
	if (callbackCase != CALLBACK_CASE) {
		string listName = /** \nList: *//***tag:listName*//**/"List1"/**/;
		List list = List(listName);
		Variant partitionId = /** \nPartition ID: *//***tag:partitionId*//**/0/**/;
		treenode puller = /** \nPuller: *//***tag:puller*//**/item/**/;
		Array pulledArray = list.pull( 
			/** \nQuery: *//***tag:query*//**/""/**/, 
			/** \nRequest: *//***tag:requestNum*//**/1/**/, 
			numRequired, 
			puller,
			partitionId,
			/** \nFlags: *//***tag:flags*//**/0/**/);
		int numPulled = pulledArray.length;
		for (int i = 1; i <= numPulled; i++)
			nodefunction(c, current, item, conveyor, pulledArray[i], i, CALLBACK_CASE);
		if (numPulled < numRequired) {
			Array backOrders = list.backOrders(partitionId);
			List.BackOrder backOrder = findmatch(backOrders.length, backOrders[count].as(List.BackOrder).puller == puller, backOrders[count], 1);
			if (objectexists(backOrder))
				eventlisten(backOrder, "OnFulfill", c, 0, current, item, conveyor, LIST_ON_FULFILL_VALUE, LIST_ON_FULFILL_TOTAL_FULFILLED, CALLBACK_CASE);
		}
	} else {
		current = param(1);
		item = param(2);
		conveyor = param(3);
		Variant pulled = param(4);
		int numFulfilled = param(5);
		/** \nOn Pulled: */
/***tag:onPulled*//**//**/
		return 0;
	}
}
} //******* PickOption End *******\\

There are several problems with this code:

  • By default line 16 reads
    string listName = /** \nList: *//***tag:listName*//**/ListName/**/;
    This gives a compiler error because ListName without quotes is not a string.
  • Line 32
    Array backOrders = list.backOrders(partitionId)
    gives an error because the list backorders requires a .toArray().
  • Line 34: if(objectexists(backOrder)) makes no sense to the compiler. I guessed it should just be if(backOrder).
  • The problem I didn't figure out yet: what to put in eventlisten as first argument?! It seems to require an Object but List.BackOrder is not an object... so what do we listen for?

Of course fixing this in a next release is great, but for now I would appreciate it if you could give me the code that should have been there, as this option would really help out a customer with a specific problem they are having right now.

Thanks!

FlexSim 17.2.1
bug reporttriggerslist pull
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

Matthew Gillespie avatar image
2 Likes"
Matthew Gillespie answered Mischa Spelt commented

Change backorder

eventlisten(backOrder, ...);

to backOrder.as(treenode)

eventlisten(backOrder.as(treenode), ...);

I'll add the other issues to the dev list.

· 1
5 |100000

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

Mischa Spelt avatar image Mischa Spelt commented ·

Thanks Matt. For anyone running into the same problem in the mean time, here is the complete code for this pick option (you can just copy/paste it into the code editor, hit OK, then change the properties as usual).

{ //************* PickOption Start *************\\
/***popup:TriggerPullFromList*/
/***tag:description*//**Pull From List*/


if (/** \nCondition: *//***tag:condition*//**/true/**/) {
	int callbackCase = param(6);
	#define CALLBACK_CASE 10293
	int numRequired = /** \nRequire: *//***tag:requireNum*//**/1/**/;
	if (callbackCase != CALLBACK_CASE) {
		string listName = /** \nList: *//***tag:listName*//**/"ListName"/**/;
		List list = List(listName);
		Variant partitionId = /** \nPartition ID: *//***tag:partitionId*//**/0/**/;
		treenode puller = /** \nPuller: *//***tag:puller*//**/item/**/;
		
		Array pulledArray = list.pull( 
			/** \nQuery: *//***tag:query*//**/""/**/, 
			/** \nRequest: *//***tag:requestNum*//**/1/**/, 
			numRequired, 
			puller,
			partitionId,
			/** \nFlags: *//***tag:flags*//**/0/**/);
		int numPulled = pulledArray.length;
		for (int i = 1; i <= numPulled; i++)
			nodefunction(c, current, item, conveyor, pulledArray[i], i, CALLBACK_CASE);
		if (numPulled < numRequired) {
			Array backOrders = list.backOrders(partitionId).toArray();
			List.BackOrder backOrder = findmatch(backOrders.length, backOrders[count].as(List.BackOrder).puller == puller, backOrders[count], 1);
			if(backOrder)
				eventlisten(backOrder.as(treenode), "OnFulfill", c, 0, current, item, conveyor, LIST_ON_FULFILL_VALUE, LIST_ON_FULFILL_TOTAL_FULFILLED, CALLBACK_CASE);
		}
	} else {
		current = param(1);
		item = param(2);
		conveyor = param(3);
		Variant pulled = param(4);
		int numFulfilled = param(5);
		/** \nOn Pulled: */
/***tag:onPulled*//**//**/
		return 0;
	}


}


} //******* PickOption End *******\\


0 Likes 0 ·