Package org.jcsp.plugNplay
Class Deparaplex
java.lang.Object
org.jcsp.plugNplay.Deparaplex
- All Implemented Interfaces:
CSProcess
This demultiplexes data from its input channel to its output channel array.
Process Diagram
Description
Deparaplex is a process to convert the single stream of Object[] packets sent from aParaplex
process on the other
end of its in channel back to separate streams (its out
channels). It assumes that Paraplex
operates on the same
size array of channels as its out array. It conforms to
contract required by Paraplex
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 | Object[] | A packet carrying the paraplexed data. |
Output Channels | ||
out[] | Object | Most channels in this package carry integers. |
Example
import org.jcsp.lang.*;
import org.jcsp.plugNplay.*;
public class DeparaplexExample {
public static void main (String[] args) {
final One2OneChannel[] a = Channel.one2oneArray (3);
final One2OneChannel b = Channel.one2one ();
final One2OneChannel[] c = Channel.one2oneArray (3);
final One2OneChannel d = Channel.one2one ();
new Parallel (
new CSProcess[] {
new Numbers (a[0].out ()),
new Squares (a[1].out ()),
new Fibonacci (a[2].out ()),
new Paraplex (Channel.getInputArray (a), b.out ()),
new Deparaplex (b.in (), Channel.getOutputArray (c)),
new Paraplex (Channel.getInputArray (c), d.out ()),
new CSProcess () {
public void run () {
System.out.println ("\n\t\tNumbers\t\tSquares\t\tFibonacci\n");
while (true) {
Object[] data = (Object[]) d.in ().read ();
for (int i = 0; i invalid input: '<' data.length; i++) {
System.out.print ("\t\t" + data[i]);
}
System.out.println ();
}
}
}
}
).run ();
}
}
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ChannelInput
The input Channelprivate final ChannelOutput[]
The output Channels -
Constructor Summary
ConstructorsConstructorDescriptionDeparaplex
(ChannelInput in, ChannelOutput[] out) Construct a new Deparaplex process with the input Channel in and the output Channels out. -
Method Summary
-
Field Details
-
in
The input Channel -
out
The output Channels
-
-
Constructor Details
-
Deparaplex
Construct a new Deparaplex 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
-
-
Method Details