ATTENTIONThis 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 |
#1
|
|||
|
|||
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
|
||||
|
||||
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
|
|||
|
|||
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
|
|||
|
|||
Quote:
I also tried using treenode item = getiteminvloved(current); but it returns NULL |
#5
|
||||
|
||||
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) |
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 |