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 > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 08-20-2013
mearjun mearjun is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 123
Downloads: 5
Uploads: 0
Thanks: 27
Thanked 19 Times in 11 Posts
Rep Power: 119
mearjun will become famous soon enough
Default Problems with user commands ..!!

Hello everyone. As usual I am in facing a strange problem. I have been playing with user commands all the time and I thought I knew all. However a problem occurs when a user command is used on a onmessage trigger. The code which I wrote on the trigger works perfectly on the trigger, but if I use the same code in a user command called "onmessage" flexsim detects the msgsendingobject incorrectly.

For more details the code on the trigger is:
/**IDENTIFY NURSES AND DOCS*/
treenode current = ownerobject(c);
treenode XX = msgsendingobject();
int ID = getlabelnum(msgsendingobject,"ID");
if (msgparam(2) == 1) setlabelnum(current,"Nurse Num",ID);
if (msgparam(2) == 2) setlabelnum(current,"Doc Num",ID);
if (msgparam(2) == 2) setlabelnum(current,"WTBS",time - getlabelnum(current,"Arrival Time"));
if (msgparam(1) == 1) closeinput(current);
if (msgparam(1) == 2) openinput(current);

and the code in the onmessage user command is:
/**IDENTIFY NURSES AND DOCS*/
treenode bed = parnode(1);
treenode XX = msgsendingobject();
int ID = getlabelnum(XX,"ID");
if (msgparam(2) == 1) setlabelnum(bed,"Nurse Num",ID);
if (msgparam(2) == 2) setlabelnum(bed,"Doc Num",ID);
if (msgparam(2) == 2) setlabelnum(bed,"WTBS",time - getlabelnum(bed,"Arrival Time"));
if (msgparam(1) == 1) closeinput(bed);
if (msgparam(1) == 2) openinput(bed);

The result for node XX comes different when the code is written inside user command. Please help
  #2  
Old 08-20-2013
Steven Hamoen's Avatar
Steven Hamoen Steven Hamoen is offline
Talumis, Flexsim Distributor, The Netherlands
 
Join Date: Aug 2007
Location: Soest, NL
Posts: 854
Downloads: 43
Uploads: 0
Thanks: 391
Thanked 661 Times in 379 Posts
Rep Power: 684
Steven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond reputeSteven Hamoen has a reputation beyond repute
Default

If you read the user manual you will find that msgsendingobject() and msgparam() are only used in the OnMessage trigger. So in your usercommand you cannot use these functions and you have to use parval, parnode and parstr.
The Following 3 Users Say Thank You to Steven Hamoen For This Useful Post:
Sebastian Hemmann (08-21-2013)
  #3  
Old 08-21-2013
mearjun mearjun is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 123
Downloads: 5
Uploads: 0
Thanks: 27
Thanked 19 Times in 11 Posts
Rep Power: 119
mearjun will become famous soon enough
Default

Got it.. Thanks a ton.. Also posting the solution if someone else faces the same issue.
So instead of using msgsendingobject() command inside the user command (ie. onmessage(bed,sender) I declared
treenode bed = parnode(1);
treenode sender = parnode(2);
and wrote the commands with reference to bed and sender and on the on message trigger of the multiprocessor, I declared
treenode current = ownerobject(c);
treenode X = msgsendingobject();
then I wrote onmessage(current,X); and bingo.. it worked.
  #4  
Old 08-21-2013
mearjun mearjun is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 123
Downloads: 5
Uploads: 0
Thanks: 27
Thanked 19 Times in 11 Posts
Rep Power: 119
mearjun will become famous soon enough
Default

Quote:
Originally Posted by Steven Hamoen View Post
If you read the user manual you will find that msgsendingobject() and msgparam() are only used in the OnMessage trigger. So in your usercommand you cannot use these functions and you have to use parval, parnode and parstr.
Another quick question. Is there a way to call the item that is currently on the multiprocessor in the on message trigger as it only begins with treenode current = ownerobject(c). I tried using treenode item = parnode(1) inside on message trigger but it points to the msgsendingobject instead of the item.
I also tried using treenode item = getiteminvloved(current); but it returns NULL
  #5  
Old 08-21-2013
Sebastian Hemmann's Avatar
Sebastian Hemmann Sebastian Hemmann is offline
Flexsim User
 
Join Date: Sep 2009
Location: Braunschweig (Germany)
Posts: 439
Downloads: 52
Uploads: 0
Thanks: 472
Thanked 217 Times in 154 Posts
Rep Power: 319
Sebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to beholdSebastian Hemmann is a splendid one to behold
Default

Hi,

have you tried :

if(Content(current)==1)
{
treenode item = first(current);
}
__________________
Hemmi
The Following 2 Users Say Thank You to Sebastian Hemmann For This Useful Post:
mearjun (08-22-2013)
  #6  
Old 08-22-2013
mearjun mearjun is offline
Flexsim User
 
Join Date: Feb 2012
Posts: 123
Downloads: 5
Uploads: 0
Thanks: 27
Thanked 19 Times in 11 Posts
Rep Power: 119
mearjun will become famous soon enough
Default

Yes it almost worked. For me it worked as
treenode item;
if(content(current) == 1)
{
item = first(current);
}
Nevertheless thanks a ton for such a quick reply


Thread Thread Starter Forum Replies Last Post
User Commands mearjun Flexsim Student Forum 4 05-01-2013 06:01 PM
Excel table import using user commands ardodul Q&A 6 04-27-2012 02:04 PM
Transfer User Commands to a DLL Stephan Seidel Q&A 4 02-03-2012 03:18 AM
groups in user commands Carsten Seehafer Q&A 2 07-08-2011 01:34 AM
User Event firing - precision problems Shankar Narayan Q&A 6 02-16-2009 07:01 AM


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.