/procedures/meta/comments

Module to parse a route whose source step is a SUM step.

 2 module PARSE_SUM_STEP

Method to parse a route whose source step is a SUM step.

 5   def parse_route_from_sum_step( route_id )

Design note: The method used for validating the number of input and output routes for each step type.

If the SUM step does not have two inbound routes ...

 9     if step_inbound_routes( route_source_step_id( route_id ) ).size != 2

... log the step as has having an unexpected number of inbound routes.

 12       logger.error "SUM step with name #{route_source_step_name( route_id )} has #{step_inbound_routes( route_source_step_id( route_id ) ).size} inbound routes."

The appearance of inbound routes in first or second place has no meaning beyond the order they are delivered from the data store.

Otherwise, the SUM step does have two inbound routes.

 16     else

We get the ID of the first inbound route ...

 19       first_inbound_route_id = step_first_inbound_route( route_source_step_id( route_id ) )

... and we get the ID of the second inbound route.

 22       second_inbound_route_id = step_second_inbound_route( route_source_step_id( route_id ) )

If both inbound routes to the source step have been parsed ...

 25       if route_parsed_attribute( first_inbound_route_id ) == true and route_parsed_attribute( second_inbound_route_id ) == true

... we update the route parsed attribute to true.

 28         update_route_hash( route_id, nil, nil, true, nil, nil )

Referring to the design notes for artithmetic steps ...

... if either inbound route to the source step has a status of 'UNTRAVERSABLE' ...

 33         if route_is_untraversable?( first_inbound_route_id ) or route_is_untraversable?( second_inbound_route_id )

... we set the status of this route to 'UNTRAVERSABLE' ...

... tainting the roads off the bridge as closed if the bridge is closed.

 37           update_route_hash( route_id, nil, 'UNTRAVERSABLE', nil, nil, nil )

Otherwise, neither inbound route to the source step has a status of 'UNTRAVERSABLE' ...

 40         else

... and we sum the actualisation counts of the two routes ...

 43           sum = route_actualisation_count( first_inbound_route_id ) + route_actualisation_count( second_inbound_route_id )

... and set the actualisation count of this route to the value of the sum.

 46           update_route_hash( route_id, nil, nil, nil, sum, nil )
 47         end

Otherwise, one or both of the inbound routes have not been parsed and this route will be parsed on a later pass.

 50       end
 51     end
 52   end
 53 end