public static void main(String argv[]) { /** * ************************************************************************** Here we * instantiate three filters. * ************************************************************************** */ SourceFilter Filter1 = new SourceFilter(); TemperatureFilter Filter2 = new TemperatureFilter(); AltitudeFilter Filter3 = new AltitudeFilter(); SinkFilter Filter4 = new SinkFilter(); /** * ************************************************************************** Here we connect * the filters starting with the sink filter (Filter 1) which we connect to Filter2 the middle * filter. Then we connect Filter2 to the source filter (Filter3). * ************************************************************************** */ Filter4.Connect(Filter3); Filter3.Connect( Filter2); // This esstially says, "connect Filter3 input port to Filter2 output port Filter2.Connect( Filter1); // This esstially says, "connect Filter2 intput port to Filter1 output port /** * ************************************************************************** Here we start the * filters up. All-in-all,... its really kind of boring. * ************************************************************************** */ Filter1.start(); Filter2.start(); Filter3.start(); Filter4.start(); } // main
public static void main(String argv[]) { /** * ************************************************************************** Here we * instantiate three filters. * ************************************************************************** */ SourceFilter source = new SourceFilter( null, new PipedOutputStream[] {new PipedOutputStream()}, "FlightData.dat", null); FilterOut filterOut = new FilterOut( new PipedInputStream[] {new PipedInputStream()}, new PipedOutputStream[] {new PipedOutputStream()}, new int[] {ID.TIME, ID.ALTI, ID.PRES, ID.TEMP}); HashMap<Integer, ConversionFunction> IDsAndFuncs = new HashMap<Integer, ConversionFunction>(); ConversionFunction F2C = new Fahrenheit2Celsius(); ConversionFunction Ft2M = new Feet2Meter(); IDsAndFuncs.put(ID.TEMP, F2C); IDsAndFuncs.put(ID.ALTI, Ft2M); Converter converter = new Converter( new PipedInputStream[] {new PipedInputStream()}, new PipedOutputStream[] {new PipedOutputStream()}, IDsAndFuncs); int idsPerFrame = 4; HashMap<Integer, WildPointTest> IDsAndWildPointTests = new HashMap<Integer, WildPointTest>(); WildPointTest pressureTest = new PressureBWildPointTest(); IDsAndWildPointTests.put(ID.PRES, pressureTest); ExtrapolatorFilter extrapolater = new ExtrapolatorFilter( new PipedInputStream[] {new PipedInputStream()}, new PipedOutputStream[] {new PipedOutputStream(), new PipedOutputStream()}, IDsAndWildPointTests, idsPerFrame); SinkFilter sink = new SinkFilter( new PipedInputStream[] {new PipedInputStream()}, null, new int[] {ID.TIME, ID.ALTI, ID.PRES, ID.TEMP}, "OutputB.dat"); SinkFilter rejected = new SinkFilter( new PipedInputStream[] {new PipedInputStream()}, null, new int[] {ID.TIME, ID.PRES}, "WildPoints.dat"); /** * ************************************************************************** Here we connect * the filters starting with the sink filter (Filter 1) which we connect to Filter2 the middle * filter. Then we connect Filter2 to the source filter (Filter3). * ************************************************************************** */ sink.Connect( extrapolater, 0, 0); // This essentially says, "connect sink input port to extrapolater first output port extrapolater.Connect( converter, 0, 0); // This essentially says, "connect extrapolater input port to converter output port rejected.Connect( extrapolater, 0, 1); // This essentially says, "connect rejected input port to extrapolater second output // port converter.Connect( filterOut, 0, 0); // This essentially says, "connect converter input port to filterOut output port filterOut.Connect( source, 0, 0); // This essentially says, "connect filterOut input port to source output port /** * ************************************************************************** Here we start the * filters up. All-in-all,... its really kind of boring. * ************************************************************************** */ source.start(); filterOut.start(); converter.start(); extrapolater.start(); sink.start(); rejected.start(); } // main