jcsp.plugNplay.ints
Class DeparaplexInt
java.lang.Object
|
+--jcsp.plugNplay.ints.DeparaplexInt
- All Implemented Interfaces:
- CSProcess
- public final class DeparaplexInt
- extends Object
- implements CSProcess
This demultiplexes data from its input channel to its output channel array.
Process Diagram
_______________ out[0]
| |--------->
in | | .
---->| DeparaplexInt | .
| | .
|_______________|--------->
out[n-1]
Description
DeparaplexInt is a process to convert the single stream of
int[] packets sent from a ParaplexInt
process on the other
end of its in channel back to separate streams (its out
channels). It assumes that ParaplexInt
operates on the same
size array of channels as its out array. It conforms to
contract required by ParaplexInt
for a process receiving its packets.
In each cycle, it inputs one packet and outputs its contents in parallel
to each of its output channels.
The parallel output means that the process will wait until each item is accepted
by every channel -- in whatever order is demanded by its environment.
The ordering of the channels in the out array, therefore, makes
no difference to the functionality of this process.
Channel Protocols
Input Channels |
in |
int[] |
A packet carrying the paraplexed data.
|
Output Channels |
out[] |
int |
Most channels in this package carry integers.
|
Example
import jcsp.lang.*;
import jcsp.plugNplay.*;
class DeparaplexIntTest {
public static void main (String[] args) {
final One2OneChannelInt[] a = One2OneChannelInt.create (3);
final One2OneChannel b = new One2OneChannel ();
final One2OneChannelInt[] c = One2OneChannelInt.create (3);
final One2OneChannel d = new One2OneChannel ();
new Parallel (
new CSProcess[] {
new NumbersInt (a[0]),
new SquaresInt (a[1]),
new FibonacciInt (a[2]),
new ParaplexInt (a, b),
new DeparaplexInt (b, c),
new ParaplexInt (c, d),
new CSProcess () {
public void run () {
System.out.println ("\n\t\tNumbers\t\tSquares\t\tFibonacci\n");
while (true) {
int[] data = (int[]) d.read ();
for (int i = 0; i < data.length; i++) {
System.out.print ("\t\t" + data[i]);
}
System.out.println ();
}
}
}
}
).run ();
}
}
- Author:
- P.H.Welch
- See Also:
ParaplexInt
,
MultiplexInt
,
DemultiplexInt
Method Summary |
void |
run()
The main body of this process. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DeparaplexInt
public DeparaplexInt(ChannelInput in,
ChannelOutputInt[] out)
- Construct a new DeparaplexInt process with the input Channel in and the output
Channels out. The ordering of the Channels in the out array make
no difference to the functionality of this process.
- Parameters:
in
- the input channelout
- the output Channels
run
public void run()
- The main body of this process.
- Specified by:
run
in interface CSProcess
Submit a bug or feature to jcsp-team@ukc.ac.uk
Version 1.0-rc4 of the JCSP API Specification (Copyright 1997-2000 P.D.Austin and P.H.Welch - All Rights Reserved)
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.