Hello,
I have a system with atoms with two different names and I'd like to send them from a server to five different channels. One type of atom by channel 1 and the other type by channels from 2 to 5. I don't know how to modify the option "By atom name: if the atom name of the 1st atom in the queue matches AtomName then send to channel 1 else 2." to be able to say "else 2, 3, 4, 5". I have problems with the characters i use.
Can anyone help me?
Thanks!
Carnm
Coding question
- HarryBunnik
- Posts: 362
- Joined: Monday 07 February, 2011 - 11:22
Re: Coding question
Ha Carnm,
You can change the SendTo code to something like:
All atoms with the name "..." will be send through channel 1, else it will go through channel 2.
However, if you have many of those decision points, you might want to set a label on the product indicating which product type it is and route your product on that. CompareText is a relatively slow function, so a lot of compares will slow down your simulation. If there is only one point, it won't be such a big deal, since you have to set the label as well.
Cheers,
Harry
You can change the SendTo code to something like:
Code: Select all
If(
CompareText(Name(first(c)), [...]) = true,
1,
2
)
However, if you have many of those decision points, you might want to set a label on the product indicating which product type it is and route your product on that. CompareText is a relatively slow function, so a lot of compares will slow down your simulation. If there is only one point, it won't be such a big deal, since you have to set the label as well.
Cheers,
Harry
Re: Coding question
Thanks Harry,
but my point is that instead of sending atoms named "..." by channel 2, i want them to be sent by any of channels 2, 3, 4 or 5. I want to modify the order but it doesn't compile:
If(
CompareText(Name(first(c)), [...]) = true,
1,
2 3 4 5
)
(this is what i tried to do but it doesn't work, i think it's matter of parenthesis or somenthing like that)
but my point is that instead of sending atoms named "..." by channel 2, i want them to be sent by any of channels 2, 3, 4 or 5. I want to modify the order but it doesn't compile:
If(
CompareText(Name(first(c)), [...]) = true,
1,
2 3 4 5
)
(this is what i tried to do but it doesn't work, i think it's matter of parenthesis or somenthing like that)
- HarryBunnik
- Posts: 362
- Joined: Monday 07 February, 2011 - 11:22
Re: Coding question
Ah, ok. I was a bit to quick with reacting...
You could do:
Or search for a randomly open channel (a small change based on SendTo statement 4 of the server):
Or in order:
In the last case you've got to set the Label([ExitNotOne]) back to 0 at the start of a simulation run. You can do this on the OnEntry of the Server, with:
So there are several options.
Cheers,
Harry
You could do:
Code: Select all
If(
CompareText(Name(first(c)), [...]) = true,
1,
dUniform(2, 5)
)
Code: Select all
If(
CompareText(Name(first(c)), [...]) = true,
1,
IndexMax(NrOC(c)-1, OCReady(Count + 1,c)*Random(100000)) + 1
)
Code: Select all
If(
CompareText(Name(first(c)), [...]) = true,
1,
Do(
Inc(Label([ExitNotOne], c)),
Mod(Label([ExitNotOne], c) -1, 4) + 1
)
)
Code: Select all
If(
Input(c) = 1,
Label([ExitNotOne], c) := 0
)
Cheers,
Harry