question

JIANYUAN, HALLEY L avatar image
0 Likes"
JIANYUAN, HALLEY L asked JIANYUAN, HALLEY L commented

Why doesn't the port open/closed as specified in the code?

Hello all,

I'm trying to open/close port when the value recorded in the global table exceeds a certain amount but even though there is no error message when running, the port doesn't seem to open/close.

In the model below, both processor 1 and 2 adds a number to Table("GlobalTable1")[1][1] when there's an item being processed. If the number hits 5, the input port should close and only opens when the number drops below 5.

However when running, I've observed that Table("GlobalTable1")[1][1] goes up to 20 when it should not be able to go above 5. I suspect it has to do with the maximum content of both processor being 10 and therefore adds up to 20 but since the input port should be closed I'm not sure how items are still being sent.

Thanks for taking your time to read!

test-9.fsm

global tableitem flowports controlobject referencing
test-9.fsm (29.7 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Phil BoBo avatar image
0 Likes"
Phil BoBo answered JIANYUAN, HALLEY L commented

Your code is trying to close and open the input of the global table.

If you want to close the input of the processor, then you need to specify the processor as the involved object.


involved.png (83.7 KiB)
· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

JIANYUAN, HALLEY L avatar image JIANYUAN, HALLEY L commented ·

Hello @phil.bobo,

I've made the changes but it seems like now processor 1&2 could only process 6 items before being "Stuck" (meanwhile, the value at global table shows 0). The only change I've made was to specify the object as current. Do you know what's wrong with changing that?

Object involved = /** \nObject: */ /***tag:object*//**/current/**/;

test-9.fsm

0 Likes 0 ·
test-9.fsm (29.8 KiB)
Phil BoBo avatar image Phil BoBo ♦♦ JIANYUAN, HALLEY L commented ·

That's what your logic is doing. You aren't closing the input until something enters.

So when the fifth item enters one of the processors, you are only closing that one processor and the other processor is still available to receive another item. Once it receives the next item, it closes itself so that it doesn't receive another after that one.

Change your logic to close and reopen both processors at the same time instead of individually.

0 Likes 0 ·
JIANYUAN, HALLEY L avatar image JIANYUAN, HALLEY L commented ·

Hi @phil.bobo,

Is there a way to refer to the items in the other processor without referencing the value when it was created? Does current.centerobjects[1] works this way? If so, could I use the exact centerobjects[1] for processor 3 and 4 in the same way?

0 Likes 0 ·
Phil BoBo avatar image Phil BoBo ♦♦ JIANYUAN, HALLEY L commented ·

Yes, you can reference the other objects and the items in the other processor.

Yes, you can use current.centerObjects[1] to reference the other processor in your model.

Yes, you can do that same thing with processor 3 and 4.

0 Likes 0 ·
JIANYUAN, HALLEY L avatar image JIANYUAN, HALLEY L Phil BoBo ♦♦ commented ·

Thank you for your help @phil.bobo!!

0 Likes 0 ·