Changes between Version 23 and Version 24 of Java API

Show
Ignore:
Timestamp:
12/04/12 12:58:47 (12 years ago)
Author:
jorisborgdorff
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Java API

    v23 v24  
    236236=== Filters === 
    237237 
    238 A conduit filter is like a mapper, but is only applied to a single conduit. The implementation is also more light-weight, and theoretically it is allowed to modify the timestamps of messages, or drop them all-together. To implement a filter, extend {{{muscle.core.conduit.filter.AbstractFilter}}}. This uses generics to indicate what values it should convert between. It is allowed to define a constructor, this should then either be empty or take a single {{{double}}} argument. The only function that should be overridden is apply() and this should call put() as many times as it wants to send a message. A simple multiplication-filter would look as follows 
     238A conduit filter is like a mapper, but it is only applied to a single conduit. The implementation is also more light-weight, and theoretically it is allowed to modify the timestamps of messages, or drop them all-together. To implement a filter, extend {{{muscle.core.conduit.filter.AbstractFilter}}}. This uses generics to indicate what values it should convert between. It is allowed to define a constructor which may take zero arguments or a single {{{double}}}. The only function that should be overridden is apply() and this should call put() as many times as it wants to send a message. A simple multiplication-filter would look as follows 
    239239{{{ 
    240240public class MultiplicationFilter extends muscle.core.conduit.filter.AbstractFilter<double[], double[]> { 
     
    247247    @Override 
    248248    public void apply(Observation<double[]> obs) { 
    249         double[] data = obs.getData(); 
     249        // Do not modify the original data of the submodel, so make a private copy and use the resulting data 
     250        double[] data = obs.privateCopy(SerializableDatatype.DOUBLE_ARR).getData(); 
    250251 
    251252        // perform multiplication 
     
    254255        } 
    255256 
    256         // Create a new observable to send 
     257        // Create a new observation to send, with the same timestamps as the original 
    257258        Observation<double[]> multObs = obs.copyWithData(data); 
    258259        put(multObs); 
     
    261262}}} 
    262263 
    263 In the {{{muscle.core.conduit.filter}}} are some examples of filters which are ready to use. 
    264  
     264In the {{{muscle.core.conduit.filter}}} are some examples of filters which are ready to use, they are explained in the [[Configuration|Configuration section]]. 
    265265=== Terminals === 
    266266