question

NicolaiNielsen avatar image
0 Likes"
NicolaiNielsen asked NicolaiNielsen commented

Process timeValues By Case and Different Time for Nth Item

I'm in the situation where I have a process, where there are manufactured 3 products; A, B and C.

Process times (sec) are as so far:

A = 30

B = 34

C = 38

Furthermore, during the manufacturing process, we have quality checks and clean-up of the manufacturing equipment, which is conducted every 8th product. It adds 4 seconds to each product process time.

The default code within Flexsim are as follows and I simply want to combine them into one code:

Code for Values By Case

Object current = ownerobject(c);

Object item = param(1);

/***popup:ValuesByCaseLabel:valuestr=Time:doreturn=1*/

/**Values By Case*/


Variant value = /** \nCase Function: *//***tag:ValueFunc*//**/item.Type/**/;

/** \nCases:\n*/

double retValue = /**\nDefault Port:*//***tag:default*//**/30/**/;

/***tagex:data*/

if (value == /**\nCase: *//**/1/**/){ retValue = /** Time: *//**/34/**/;}

if (value == /**\nCase: *//**/2/**/){ retValue = /** Time: *//**/38/**/;}/***//**/ /**/



return retValue/**/;


Code for Different Time for Nth Item

Object current = ownerobject(c);

Object item = param(1);

/***popup:NthItem*/

/**Different Time for Nth Item*/

int cnt = /**\nN: *//***tag:count*//**/8/**/;


if (fmod(getinput(current),cnt) == 0)

return /**\nTime for Nth item: *//***tag:time_nth*//**/34/**/;

else return /**\nTime for all others: *//***tag:time_others*//**/30/**/;



Can anyone assist or propose a solution to this problem


FlexSim 23.0.1
custom process time
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

Felix Möhlmann avatar image
0 Likes"
Felix Möhlmann answered NicolaiNielsen commented

Mostly you just have to delete unneeded parts of the code and slightly alter the final to lines.

I would start by removing the markup (light grey text). It is used to create the GUI in the processor's properties, which won't work when you combine the options anyway. You can do this with the button in the lower of the code editor window. This will mark the code as "Custom Code" in the first line.1673005186022.pngThen you delete the first "return", since you don't want to immediately return the value from the "Values by Case" code, but rather check whether it needs to be modified further. Also remove the duplicate declarations of "current" and "item".

You then just need to edit the final to lines to either return the "retValue" (determined by "Values by Case") or that value plus 4.

/**Custom Code*/
Object current = ownerobject(c);
Object item = param(1);

Variant value = item.Type;
double retValue = 30;
if (value == 1){ retValue = 34;}
if (value == 2){ retValue = 38;}

int cnt = 8;

if (fmod(getinput(current),cnt) == 0)
 return retValue + 4;
else return retValue;

· 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.

NicolaiNielsen avatar image NicolaiNielsen commented ·
Hi Felix,


Thank you for the quick response, the answer works, thanks! :)

0 Likes 0 ·