MATLAB Answers

David
0

Attribute Function sets output variables to zero on first use

Asked by David
on 29 Nov 2013
Latest activity Commented on by farnaz
on 1 Jun 2014
I seem to be having trouble with the AttributeFunction in SimEvents. On first execution, it always sets the output attributes to zero. At first I thought this was something specific to my model, but then I modified the supplied demo 'doc_outsw_attr' to use AttributeFunction block instead of SetAttribute and simplified it to set the Zone attribute to 1 in all cases. This version crashed because the subsequent Output Switch requires a valid number from 1-3 and the Zone attribute was set to zero.
I verified this while stepping through the simulation. For some reason, the first entity through the AttributeFunction gets zero assigned to its output attribute.
Can anyone explain this or identify a fix for it?
Best regards, David
UPDATE: I have more information. It looks like the setting of the output attributes is delayed by one entity in all cases. For the first one, this translates to zero, but the second one is getting the first one's calculation and the third is getting the second one's calculation.
I am getting a race condition warning: Warning: Race condition detected between 'testing/Attribute Function' and 'testing/Attribute Function/__DMLF__SA__'. The former block initiates function calls during entity advancement, but the latter block responds to such function calls after the entity has arrived. This may cause the latter block to process the entity using outdated signal values. To avoid this, between the two blocks, please insert a Single Server block with a service time of 0. You can disable this diagnostic by setting 'Response to function call delayed relative to entities' diagnostic to 'none' in the SimEvents Diagnostics tab of the Configuration Parameters dialog.
I don't know how to handle this suggestion because this is within the AF block itself and I do not have access to this part of the model. I find it hard to believe that this operates this way. After all, this is basic SimEvents package.
Any advice?
Best regards, David

  1 Comment

I have this problem too, can u tell me how du solve it

Sign in to comment.

1 Answer

Answer by Devdatt Lad on 2 Dec 2013
 Accepted Answer

Looks like the Attribute Function block in this model has gotten corrupted somehow. Can you pull in a new instance from the library browser and copy your code into it? If that doesn't work, please contact Tech Support with this.

  0 Comments

Sign in to comment.