问题

Laurenz Peleman avatar image
0 喜欢"
Laurenz Peleman 已提出 Laurenz Peleman 已评论

Delay when changing the rank of items in Object
更改对象中项目排名时的延迟

Hello everyone 大家好

I encountered a problem when I was trying to change the order of items in a queue based on a label value. Any time an item with label "label" = 5 enters, it should be processed before any other item in the queue. I wrote the code below for the OnEntry trigger.
当我尝试根据标签值更改队列中项目的顺序时,我遇到了一个问题。每当标签为“label”= 5 输入item时,都应先于队列中的任何其他item标签进行处理。我为 OnEntry 触发器编写了以下代码。

Now, the code results in the outputport being opened before the items are shuffled. Hence, the item initially at rank 1, so before the entry trigger, is passed to the processor, not the one I want. Only after the wrong item was passed, the remaining items are ordered correctly.
现在,该代码会导致在洗牌项之前打开输出端口。因此,item最初处于等级 1 的位置,即在进入触发器之前,被传递给处理器,而不是我想要的处理器。只有在错误item通过后,其余项目才会正确排序。

Is there an easy way to overcome the apparent delay on the item sorting step, or am I doing something wrong?
有没有一种简单的方法可以克服分拣步骤的item明显延迟,或者我做错了什么?

Many thanks in advance
提前非常感谢

  1. Object item = param(1);
  2. Object current = ownerobject(c);
  3. int port = param(2);
  4. { // ************* PickOption Start ************* //
  5. if (item.label == 5) {
  6. treenode itemConsidered = current.subnodes[current.subnodes.length];
  7. itemConsidered.rank = 1;
  8. openoutput(current);
  9. }
  10. } // ******* PickOption End ******* //
FlexSim 17.0.0  灵活模拟 17.0.0
rank in queue 队列排名
5 |100000

最多12个附件(包括图片)可被使用,其中每个附件最多23.8 MiB,总共最多47.7 MiB。

1 条回复

Steven Hamoen avatar image
0 喜欢"
Steven Hamoen 已解答 Laurenz Peleman 已评论

@Laurenz Peleman Have you tried using a senddelayedmessage with delay 0 and in that onmessage trigger open the output? This usually solves these types of problems.
@Laurenz Peleman 您是否尝试过使用延迟为 0 的 senddelayedmessage 并在该 onmessage 触发器中打开输出?这通常可以解决这些类型的问题。

· 3
5 |100000

最多12个附件(包括图片)可被使用,其中每个附件最多23.8 MiB,总共最多47.7 MiB。

Laurenz Peleman avatar image Laurenz Peleman 已评论 ·
Laurenz Peleman 已评论·2017年3月24日 在 22:35

Hi Steven 嗨,史蒂文

Thanks for your reply. This would indeed work around the problem, however it creates an additional layer of communication to a model which is already quite complex.
感谢您的回复。这确实可以解决这个问题,但是它为已经非常复杂的模型创建了一个额外的通信层。

If there is no other solution, I can solve it this way, but a more direct solution would be interesting, if available of course.
如果没有其他解决方案,我可以用这种方式解决,但当然,如果有的话,更直接的解决方案会很有趣。

Another question related to this topic: is it normal that I have to declare the item explicitly as the treenode itemConsidered to make the command itemConsidered.rank work? If I replace itemConsidered.rank by item.rank, I get an exception in the system console.
与此主题相关的另一个问题:我必须将 显item式声明为 treenode itemConsidered 才能使命令 itemConsidered.rank 正常工作吗?如果我将 itemConsidered.rank 替换为 item.rank,则会在系统控制台中出现异常。

0 喜欢 0 ·
Steven Hamoen avatar image Steven Hamoen Laurenz Peleman 已评论 ·
Steven Hamoen Laurenz Peleman 已评论·2017年3月27日 在 6:55 PM

@Laurenz Peleman Having to use the senddelayedmessage is a very common practice within Flexsim.
@Laurenz Peleman 必须使用 senddelayedmessage 是 Flexsim 中非常常见的做法。

I understand why try to avoid it but I don't think you get around it with this problem because opening the output straight away doesn't give the object enough time to perform what it has to do on the onentry.
我理解为什么要尝试避免它,但我认为您无法解决这个问题,因为立即打开输出不会给对象足够的时间来执行它在入口上必须执行的操作。

Concerning the item.rank not working, I have tested a bit with 17.0.3 and there it doesn't give any error reports, so maybe updating will fix it for you. The dot notation is new to Flexsim and still constantly in development so keeping up with the updates might help you here.
关于item.rank不起作用,我已经用17.0.3进行了一些测试,它没有给出任何错误报告,所以也许更新会为您修复它。点符号是 Flexsim 的新功能,并且仍在不断开发中,因此跟上更新可能会对您有所帮助。

0 喜欢 0 ·
Laurenz Peleman avatar image Laurenz Peleman Steven Hamoen 已评论 ·
Laurenz Peleman Steven Hamoen 已评论·2017年3月28日 在 4:18 PM

Thank you @steven.hamoen, the update solved the issue.
谢谢@steven.hamoen,更新解决了这个问题。

0 喜欢 0 ·