Changes between Version 32 and Version 33 of Java API
- Timestamp:
- 06/09/15 11:18:18 (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Java API
v32 v33 264 264 A terminal, either a source or a sink, may generate or store values from a conduit. It can be used to perform I/O in a way that is transparent in MUSCLE, so instead of writing to a file, messages can be sent over a conduit and processed by a terminal. It can also be used to test submodels, by studying it in isolation and exactly controlling what messages will be sent or received over the different conduits. 265 265 266 The Source class uses Java Generics to specify what data type {{{T}}} will be generated. To extend a Source, it is necessary to implement the {{{Observation<T> take()}}} and {{{isEmpty()}}} methods. In {{{take}}} a message is generated, while isEmpty defines whether the Source will have another message. An example implementation, which would generate five random double arrays, is the following:266 The Source class uses Java Generics to specify what data type {{{T}}} will be generated. To extend a Source, it is necessary to implement the {{{Observation<T> generate()}}} and {{{isEmpty()}}} methods. In {{{take}}} a message is generated, while isEmpty defines whether the Source will have another message. An example implementation, which would generate five random double arrays, is the following: 267 267 {{{ 268 268 public class RandomDoubleSource extends Source<double[]> { 269 269 int iteration = 0; 270 270 @Override 271 public Observation<double[]> take() {271 public Observation<double[]> generate() { 272 272 iteration++; 273 273 double[] data = new double[10];