Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For the simple river I made specialized implementations of output and input items. So, in my case I have FlowInputItem and FlowOutputItem, which were inherited from Backbone.InputItem and Backbone.OutputItem, respectively. Both classes has an initialize method, where a reference directly to the corresponding data in the model engine can be set. - in my case simply an index in a array.

The Update method in my LinkableComponent is very similar to the pattern used in the old wrapper implementation of the the GetValues method. First update methods are call for every input exchange items. This will ensure that data from outside in feed into my engine. Then the time step is made, and finally all output exchange items are populated with the data calculated by the engine. However, there is a potential performance problem. I have assumed that I do not know if anyone will ask my output items for data, which means that each and every output item must be updated after each time step. I could have checked if the output item had consumers and only update items with consumers. However, I think that it would be very unfortunate if you are required to add a consumer to an output item in order to get the data. A better solution would be to override the [] method in the Values property so data is only copied to the output exchange item when needed. It turns out that, when we use the System list this is not possible. So, we could consider to make out own implementation of IList.

Unit Test