lib/spnet/core/block.rb in spnet-0.1.5 vs lib/spnet/core/block.rb in spnet-0.1.6

- old
+ new

@@ -20,10 +20,11 @@ # A new instance of Block. # @param [Hash] args Hashed arguments for initialization. See Block::ARG_SPECS # for details of which keys are required. def initialize args = {} hash_make Block::ARG_SPECS, args + @initial_params = collect_params end # Execute the block algorithm. # @param [Fixnum] count The number of steps to execute. Passed on to the algorithm Proc. def step count @@ -31,16 +32,32 @@ end # Produces a BlockState object based on this Block object. # @return [BlockState] def export_state - port_params = {} + params = collect_params + + # discard the params that are the same as the initial port params + params.keys.each do |key| + if params[key] == @initial_params[key] + params.delete key + end + end + + BlockState.new(:class_sym => self.class.to_s.to_sym, :params => params) + end + + private + + def collect_params + params = {} + @in_ports.each do |name, port| if port.is_a?(ParamInPort) - port_params[name] = port.get_value + params[name] = port.get_value end end - BlockState.new(:class_sym => self.class.to_s.to_sym, :port_params => port_params) + return params end end end