FlexSim Community Forum

FlexSim Community Forum (https://archive.flexsim.com/index.php)
-   Q&A (https://archive.flexsim.com/forumdisplay.php?f=66)
-   -   Move Decision Point along the Conveyor by code (https://archive.flexsim.com/showthread.php?t=3222)

Jing Chen 12-06-2015 04:29 AM

Move Decision Point along the Conveyor by code
 
Hello everyone,

I was wondering in Conveyor Module if it is possible to change the position of Decision Point along the conveyor by code rather than by dragging?

I would like the position of DP in the conveyor depend on a dynamic value rather than a fixed value.

Is there a solution?
Thanks.

Jing Chen

Jörg Vogel 12-13-2015 04:40 PM

Independent of a Test, you have to know flexsim is a discret Event Simulation. Thus the events are created upon Events. If an Item enters a conveyor the events are created, too. If you then change the position of photo eyes the previous events still exists. The new positions doesn't count at all, until a new event take a credit from the change. There positions get only an effect if the engine computes those new positions and remove existing old events automatically. If you test on your own such behaviour you can use it in your models, otherwise it won't work. in contrast to Flexsim 7.5 you can use the process flow in Flexsim 7.7, which has the ability to change the models in smaller time steps than the Flexim standard model. But that have you test on your own, too.
Generally, changing photo eyes positions works only on items that haven't entered a conveyor at all. In contrast to that statement Flexsim must have the ability to predict what an user want achieve. That is impossible.
Jörg

Jing Chen 12-13-2015 11:15 PM

Thanks, Jörg.
In fact, I don't want to change the position dynamic during model running. I want to change the position of Decision Point in Conveyor Module before model running, cause I may change the layout of model.
I had change the position of DecisionPoint in BasicConveyor by code, and it works well. So I also want to change the DP in Conveyor Module.

I will further test on my own.
Thank you for other reply. ^_^

Jing

arunkrmahadeva 12-14-2015 01:25 AM

Dear Jing,

Have you tried setloc() command on the reset trigger of the decision point? Choose the model coordinate system instead of conveyor coordinate system.

Regards,

Arun KR

Jörg Vogel 12-14-2015 05:14 AM

Hello Jing,

next line changes the distance of a decision point. But it doesn't change the visual position.
Code:

set(node("/StraightConveyor4>variables/conveyorPoints/2/distAlong",model()),7);
Wherein 2 is the rank in the container node "conveyorPoints" and 7 is the set distance from the entry point.
The code works, too, while the model is running. You have to test on your own, which entered item uses the changed location firstly.

Jörg

Jing Chen 12-15-2015 12:17 AM

Find a method!
 
Many thanks to advice of Arun KR and Jörg.
I try to combine the advantage of two methods, and it works well!
Now I share with everyone.


treenode conveyor = node("Conveyor1", model());
treenode dp = node("DP1", model());
double distance = 9;
double x = distance - 0.5*xsize(dp);
double y = 0.5*ysize(dp);
double z = x/getvarnum(conveyor, "length")*getvarnum(conveyor, "rise")+0.01;

double model_x = vectorprojectx(conveyor,x,y,z,model());
double model_y = vectorprojecty(conveyor,x,y,z,model());
double model_z = vectorprojectz(conveyor,x,y,z,model());

setloc(dp,model_x,model_y,model_z);
set(node("/distAlong",node(">variables/conveyorPoint/1+",dp)),distance);


Node "dp" is the reference of the decision point want to edit, node "conveyor" is where the dp on, the value distance is the set distance from the entry point.

Phil BoBo 12-15-2015 02:03 PM

Rather than explicitly setting that variable, you should call this:

function_s(dp,"finalizeSpatialChanges");

Axel Kohonen 06-06-2016 12:09 AM

Hi,

I was not sure what all code was needed, but it seems that at least in Flexsim 2016 the only code that is needed for setting the x location along the conveyor is

Code:

//define the position along the conveyor
double dpPositionAlongConveyor= 4;
//the x position is the position along the conveyor
setloc(dp,dpPositionAlongConveyor,0,0);

//update the spatial changes (the decision point is
//on the conveyor so update the conveyor)
function_s(newConveyor,"finalizeSpatialChanges");

Is this correct?

Axel

Jing Chen 06-06-2016 05:20 AM

Hi,Axel
I think your code maybe not you needed. Because DP is under the model rather than the conveyor. Your code would move the DP out of conveyor.

I suggest you try this:

set(node("/distAlong",node(">variables/conveyorPoint/1+",dp)),distance);
function_s(conveyor, "clearNonLockedPoints");
function_s(conveyor, "notifyEdgePointsOnEdgeMoved");
function_s(conveyor,"finalizeSpatialChanges");

Node "dp" is the reference of the decision point want to edit, node "conveyor" is where the dp on, the value "distance" is the set distance from the entry point.


All times are GMT -6. The time now is 02:45 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.