prj03-group06/src/weather/WeatherController.java
@Override
	public void run() {
		/**
		 * The moon phase calculation takes some time to complete,
		 * moving outside of the threaded loop
		 */
		int moon = extractMoonPhase();
		while(writer != null && !Thread.interrupted()) {
			station.setCity(gui.getCity());
			gui.setTitleBar();
			
			byte[] packet = station.getNext();
			
			int temp = extractTemp(packet);
			int humid = extractHumid(packet);
			int pressure = extractPressure(packet);
			int windspd = extractWindSpd(packet);
			int winddir = extractWindDir(packet);
			int rain = extractRain(packet);
			Date date = new Date();
			int sunrise = extractSunrise(packet);
			int sunset = extractSunset(packet);

			String toWrite = dataToString(temp, humid, pressure, windspd, winddir, rain, date);
			writer.println(toWrite);
			writer.flush();
			
			gui.setTemp(temp);
			gui.setHumid(humid);
			gui.setPressure(pressure);
			gui.setWind(windspd, winddir);
			gui.setMoonPhase(moon);
			gui.setRain(rain);
			gui.setDate(date);
			gui.setTime(date);
			gui.setSunrise(sunrise);
			gui.setSunset(sunset);
			gui.graphTick();
			
			sendWeatherSummaryState(temp, humid, pressure, windspd, moon, rain, date, sunrise, sunset);
		}
		writer.close();
	}
/**
	 * Run method extracts the data from the packets and passes the data into the WeatherGUI.
	 */
Run method extracts the data from the packets and passes the data into the WeatherGUI.
Run method extracts the data from the packets and passes the data into the WeatherGUI .
@Override
	public void run() {
		/**
		 * The moon phase calculation takes some time to complete,
		 * moving outside of the threaded loop
		 */
		int moon = extractMoonPhase();
		while(writer != null && !Thread.interrupted()) {
			station.setCity(gui.getCity());
			gui.setTitleBar();
			byte[] packet = station.getNext();
			int temp = extractTemp(packet);
			int humid = extractHumid(packet);
			int pressure = extractPressure(packet);
			int windspd = extractWindSpd(packet);
			int winddir = extractWindDir(packet);
			int rain = extractRain(packet);
			Date date = new Date();
			int sunrise = extractSunrise(packet);
			int sunset = extractSunset(packet);
			String toWrite = dataToString(temp, humid, pressure, windspd, winddir, rain, date);
			writer.println(toWrite);
			writer.flush();
			gui.setTemp(temp);
			gui.setHumid(humid);
			gui.setPressure(pressure);
			gui.setWind(windspd, winddir);
			gui.setMoonPhase(moon);
			gui.setRain(rain);
			gui.setDate(date);
			gui.setTime(date);
			gui.setSunrise(sunrise);
			gui.setSunset(sunset);
			gui.graphTick();
			sendWeatherSummaryState(temp, humid, pressure, windspd, moon, rain, date, sunrise, sunset);
		}
		writer.close();
	}
@ Override public void run ( ) { /**
		 * The moon phase calculation takes some time to complete,
		 * moving outside of the threaded loop
		 */ int moon = extractMoonPhase ( ) ; while ( writer != null && ! Thread . interrupted ( ) ) { station . setCity ( gui . getCity ( ) ) ; gui . setTitleBar ( ) ; byte [ ] packet = station . getNext ( ) ; int temp = extractTemp ( packet ) ; int humid = extractHumid ( packet ) ; int pressure = extractPressure ( packet ) ; int windspd = extractWindSpd ( packet ) ; int winddir = extractWindDir ( packet ) ; int rain = extractRain ( packet ) ; Date date = new Date ( ) ; int sunrise = extractSunrise ( packet ) ; int sunset = extractSunset ( packet ) ; String toWrite = dataToString ( temp , humid , pressure , windspd , winddir , rain , date ) ; writer . println ( toWrite ) ; writer . flush ( ) ; gui . setTemp ( temp ) ; gui . setHumid ( humid ) ; gui . setPressure ( pressure ) ; gui . setWind ( windspd , winddir ) ; gui . setMoonPhase ( moon ) ; gui . setRain ( rain ) ; gui . setDate ( date ) ; gui . setTime ( date ) ; gui . setSunrise ( sunrise ) ; gui . setSunset ( sunset ) ; gui . graphTick ( ) ; sendWeatherSummaryState ( temp , humid , pressure , windspd , moon , rain , date , sunrise , sunset ) ; } writer . close ( ) ; }
Run method extracts the data from the packets and passes the data into the WeatherGUI.
Run method extracts the data from the packets and passes the data into the WeatherGUI .