ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Flexsim Student Forum
Downloads

Flexsim Student Forum Forum for discussion for Flexsim Students using the Flexsim Textbook.

  #1  
Old 05-05-2015
Chris tine
Guest
 
Posts: n/a
Downloads: 0
Uploads: 0
Default Problem Movement of crane

For the scenario in the attached file:

-when the new box gone through the processor in each station, it will convert from itemtype1 to itemtype2, brown color to blue color.

What we expect to happen is:
-when the blue color box is finished and waiting on the queue, it will send message to the crane to let it perform the new tasksequence which has been coded in the trigger/on message.

-The code for the queue to send messagethe code has applied to all the queues infront of the two conveyors)

/**Custom Code*/
treenode item = parnode(1);
treenode current = ownerobject(c);
int port = parval(2);



if (itemtype(current)==2) {
sendmessage(centerobject(current, 1),current);
}

-The code in crane: Trigger/on message:

/**Custom Code*/
treenode current = ownerobject(c);
treenode item = parnode(1);

treenode nts = createemptytasksequence(current,0,0);
inserttask(nts,TASKTYPE_TRAVEL,centerobject(curren t, 1),NULL);
inserttask(nts,TASKTYPE_LOAD,item,centerobject(cur rent, 1));
inserttask(nts,TASKTYPE_TRAVEL,msgsendingobject(), NULL);
inserttask(nts,TASKTYPE_LOAD,item,msgsendingobject );
inserttask(nts,TASKTYPE_TRAVEL,node("Queue3", model()),NULL);
inserttask(nts,TASKTYPE_UNLOAD,item,node("Queue3", model()));
dispatchtasksequence(nts);
Attached Files
File Type: fsm switching disk with only one queue (1).fsm (35.0 KB, 354 views)
  #2  
Old 05-06-2015
Jörg Vogel's Avatar
Jörg Vogel Jörg Vogel is offline
Flexsim User
 
Join Date: Sep 2007
Location: Hannover, Germany
Posts: 643
Downloads: 35
Uploads: 0
Thanks: 802
Thanked 665 Times in 410 Posts
Rep Power: 642
Jörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond repute
Default

Hello,

may it be possible for you to attach a model which contains only one process and not all. Thanks!
If you write a code which prints a text to the output console, you will see that the OnMessage Trigger of the Crane8 is never executed. Your model behave different as you expect.
Please build a smaller model. Test a normal material flow without any changes to the flow. Develop a small part of the flow you want to exchange. Anytime you can place in the source code commands which print text or numbers to the output console to test what happens in your code. Another method is to use the debugger with the break points.
Another hint the command line
Code:
treenode item = parnode(1);
from one function won't work in any function it is typically for a bunch of functions and not all. In the OnMessage Trigger it doesn't work as you assume. It is better to send the reference to the item as a number in the message parameter 1 to 4. Then you you get access to the parameter by converting the number to a pointer, eg:
Code:
treenode item = tonode(msgparam(1));
Jörg
The Following 2 Users Say Thank You to Jörg Vogel For This Useful Post:
RalfGruber (05-06-2015)
  #3  
Old 05-09-2015
Chris tine
Guest
 
Posts: n/a
Downloads: 0
Uploads: 0
Default Coding and Conditions

Hi,
Thank you for your answer.
To be honest, actually I just started to learn the coding by myself, which I feel very confused about most of the codes and condition when using them. Due to some reason and time constraint, I need to solve this problem as soon as possible. Thus, would you mind explain to me what is the point of converting the number to a pointer?
As when I put that into my code on crane-trigger-on message.... It seems that have no impact on the model.
Attached Files
File Type: fsm for forum-1.fsm (21.1 KB, 367 views)
  #4  
Old 05-10-2015
Jörg Vogel's Avatar
Jörg Vogel Jörg Vogel is offline
Flexsim User
 
Join Date: Sep 2007
Location: Hannover, Germany
Posts: 643
Downloads: 35
Uploads: 0
Thanks: 802
Thanked 665 Times in 410 Posts
Rep Power: 642
Jörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond reputeJörg Vogel has a reputation beyond repute
Default

Hi Chris,

in the source code you are sending a message all transmitting parameters have to be numbers. The reference item is a pointer. But you can convert it to a number by the command tonum(obj). Therein is obj. the item.
Code:
double itemAsNumber = tonum(item);
The value is then a part of the sending parameters.
Code:
senddelayedmessage(ToObject, NumberDelayTime, FromObject, ItemAsNumber);
You can place it in any of the four message parameters.
In the OnMessage Trigger you convert the number back to a pointer with the command tonode(num).
Code:
treenode item = tonode(msgparam(1);
Important is you convert the right message parameter one to four.

ps: I can't look into your model right now.

Jörg
The Following 2 Users Say Thank You to Jörg Vogel For This Useful Post:
sagar bolisetti (05-10-2015)


Thread Thread Starter Forum Replies Last Post
Model 3d view only updates on mouse-over movement Christian Norregaard Q&A 2 09-05-2013 02:21 AM
Robot base movement Manoj Kumar Q&A 1 01-09-2013 06:03 AM
Coordinated task movement error shashanktrivedi Q&A 1 05-09-2011 08:49 AM
Crane Logic: How to find out what a crane currently is doing? Tom David Q&A 5 06-02-2008 11:57 PM
Changing the direction of flowitem movement on a processor shivrash Q&A 3 04-09-2008 10:31 PM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.