Beispiel #1
1
void StartGameWidget::SetBodyText()
{
	if (sectors.Empty()) return;

	const SectorData* sd = sectors[currentSector];
	Weather* weather = Weather::Instance();
	Vector2I pos = sd->CoreLoc();
	Vector2F pos2 = ToWorld2F(pos);
	GLASSERT(weather);
	const float AREA = float(SECTOR_SIZE*SECTOR_SIZE);
	int nPorts = 0;
	for (int i = 0; i < 4; ++i) {
		if ((1 << i) & sd->ports) {
			nPorts++;
		}
	}

	int bioFlora = 0;
	int flowers = 0;
	Rectangle2I bi = sd->InnerBounds();
	for (Rectangle2IIterator it(bi); !it.Done(); it.Next()) {
		const WorldGrid& wg = worldMap->GetWorldGrid(it.Pos().x, it.Pos().y);
		if (wg.Plant() >= 7) {
			flowers++;
		}
		else if (wg.Plant()) {
			bioFlora++;
		}
	}

	CStr<400> str;
	str.Format("%s\nTemperature=%d%%  Rain=%d%%  Land=%d%%  Water=%d%%  nPorts=%d\n"
		"bioFlora=%d%%  flowers=%d%%",
		sd->name.c_str(),
		LRint(weather->Temperature(pos2.x, pos2.y) * 100.0f),
		LRint(weather->RainFraction(pos2.x, pos2.y) * 100.0f),
		LRint(100.0f*float(sd->area) / AREA),
		LRint(100.0f*float(AREA - sd->area) / AREA),
		nPorts,
		LRint(100.0f*float(bioFlora) / AREA),
		LRint(100.0f*float(flowers) / AREA));

	bodyLabel.SetText(str.c_str());

	str.Format("%d/%d", currentSector+1, sectors.Size());
	countLabel.SetText(str.c_str());
}
Beispiel #2
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    Weather w;
    w.show();

    return a.exec();
}
Beispiel #3
0
/// Add a Weather object to the list
Weather* WeatherMgr::AddWeather(uint32 zone_id) {
    WeatherData const* weatherChances = GetWeatherChances(zone_id);

    // zone not have weather, ignore
    if (!weatherChances)
        return NULL;

    Weather* w = new Weather(zone_id, weatherChances);
    m_weathers[w->GetZone()] = w;
    w->ReGenerate();
    w->UpdateWeather();
    return w;
}
void Hardware_Initialize()
{
    // DS18B20 initialization
    sensors.begin();
    sensors.setResolution(inSoilThermometer, TEMPERATURE_PRECISION);

    pinMode(WSPEED, INPUT_PULLUP); // input from wind meters windspeed sensor
    pinMode(RAIN, INPUT_PULLUP); // input from wind meters rain gauge sensor

    pinMode(SOIL_MOIST_POWER, OUTPUT); // power control for soil moisture
    digitalWrite(SOIL_MOIST_POWER, LOW); // Leave off by defualt

    // Setup status LED
    pinMode(STATUS_LED, OUTPUT);
    digitalWrite(STATUS_LED, LOW);

    Serial.begin(9600);   // open serial over USB

    // Initialize the I2C sensors and ping them
    sensor.begin();

    //
    // You can only receive acurate barrometric readings or acurate altitiude
    // readings at a given time, not both at the same time. The following two lines
    // tell the sensor what mode to use. You could easily write a function that
    // takes a reading in one made and then switches to the other mode to grab that
    // reading, resulting in data that contains both acurate altitude and barrometric
    // readings. For this example, we will only be using the barometer mode. Be sure
    // to only uncomment one line at a time.
    //

    sensor.setModeBarometer(); // Set to Barometer Mode
    //baro.setModeAltimeter(); // Set to altimeter Mode

    // These are additional MPL3115A2 functions the MUST be called for the sensor to work.

    sensor.setOversampleRate(7); // Set Oversample rate

    //
    // Call with a rate from 0 to 7. See page 33 for table of ratios.
    // Sets the over sample rate. Datasheet calls for 128 but you can set it
    // from 1 to 128 samples. The higher the oversample rate the greater
    // the time between data samples.
    //

    sensor.enableEventFlags(); // Necessary register calls to enble temp, baro ansd alt

    return;
}
/// Add a Weather object to the list
Weather* AddWeather(uint32 zone_id)
{
    WeatherData const* weatherChances = GetWeatherData(zone_id);

    // zone does not have weather, ignore
    if (!weatherChances)
        return nullptr;

    Weather* w = new Weather(zone_id, weatherChances);
    m_weathers[w->GetZone()].reset(w);
    w->ReGenerate();
    w->UpdateWeather();

    return w;
}
Beispiel #6
0
static int RunWeather()
{
    MythScreenStack *mainStack = GetMythMainWindow()->GetMainStack();

    Weather *weather = new Weather(mainStack, "mythweather", srcMan);

    if (weather->Create())
    {
        if( weather->SetupScreens() )
            mainStack->AddScreen(weather);

        return 0;
    }

    delete weather;
    return -1;
}
Beispiel #7
0
void SunMoonStripWidget::display_surface_strip()
{
 uint8 i;
 Tile *tile;
 GameClock *clock = Game::get_game()->get_clock();
 Weather *weather = Game::get_game()->get_weather();
 bool eclipse = weather->is_eclipse();

 display_sun(clock->get_hour(), 0/*minutes*/, eclipse);

 if(!eclipse)
   display_moons(clock->get_day(), clock->get_hour());

 for(i=0;i<9;i++)
   {
    tile = tile_manager->get_tile(352+i);
    screen->blit(area.x+8 +i*16,area.y,tile->data,8,16,16,16,true);
   }

 return;
}
Beispiel #8
0
static void JSONwCheck(const KVPairs & key_value_pairs, FILE * stream_file)
{
	Weather w;
	ServeHeader(stream_file, 200, "OK", false, "text/plain");
	char key[17];
	GetApiKey(key);
	char pws[12] = {0};
	GetPWS(pws);
	const Weather::ReturnVals vals = w.GetVals(GetWUIP(), key, GetZip(), pws, GetUsePWS());
	const int scale = w.GetScale(vals);

	fprintf(stream_file, "{\n");
	fprintf_P(stream_file, PSTR("\t\"valid\" : \"%s\",\n"), vals.valid ? "true" : "false");
	fprintf_P(stream_file, PSTR("\t\"keynotfound\" : \"%s\",\n"), vals.keynotfound ? "true" : "false");
	fprintf_P(stream_file, PSTR("\t\"minhumidity\" : \"%d\",\n"), vals.minhumidity);
	fprintf_P(stream_file, PSTR("\t\"maxhumidity\" : \"%d\",\n"), vals.maxhumidity);
	fprintf_P(stream_file, PSTR("\t\"meantempi\" : \"%d\",\n"), vals.meantempi);
	fprintf_P(stream_file, PSTR("\t\"precip_today\" : \"%d\",\n"), vals.precip_today);
	fprintf_P(stream_file, PSTR("\t\"precip\" : \"%d\",\n"), vals.precipi);
	fprintf_P(stream_file, PSTR("\t\"wind_mph\" : \"%d\",\n"), vals.windmph);
	fprintf_P(stream_file, PSTR("\t\"UV\" : \"%d\",\n"), vals.UV);
	fprintf_P(stream_file, PSTR("\t\"scale\" : \"%d\"\n"), scale);
	fprintf(stream_file, "}");
}
Beispiel #9
0
void PlantScript::DoTick(U32 delta)
{
	// We need process at a steady rate so that
	// the time between ticks is constant.
	// This is performance regressive, so something
	// to keep an eye on.
	static const int MAP2 = MAX_MAP_SIZE*MAX_MAP_SIZE;
	static const int DELTA = 100*1000;	// How frequenty to tick a given plant
	static const int N_PER_MSEC = MAP2 / DELTA;
	static const int GROWTH_CHANCE = 8;
	static const int PRIME = 1553;

	static const float SHADE_EFFECT = 0.7f;

	int n = N_PER_MSEC * delta;
	Weather* weather = Weather::Instance();

	WorldMap* worldMap = context->worldMap;
	Rectangle2I bounds = worldMap->Bounds();
	bounds.Outset(-1);	// edge of map: don't want to tap over the edge.

	const Vector3F& light = context->engine->lighting.direction;
	const float		norm = Max(fabs(light.x), fabs(light.z));
	Vector2I		lightTap = { int(LRintf(light.x / norm)), int(LRintf(light.z / norm)) };
	Census*			census = &context->chitBag->census;

	for (int i = 0; i < n; ++i) {
		index += PRIME;

		int x = IndexToMapX(index);
		int y = IndexToMapY(index);

		const WorldGrid& wg = worldMap->GetWorldGrid(x, y);
		if (!wg.Plant()) continue;

		Vector2I pos2i = { x, y };
		Vector2F pos2f = ToWorld2F(pos2i);

		// --- Light Tap --- //
		const float	height = PlantScript::PlantRes(wg.Plant() - 1, wg.PlantStage())->AABB().SizeY();
		const float	rainBase		= weather->RainFraction(pos2f.x, pos2f.y);
		const float sunBase			= (1.0f - rainBase);
		const float temperatureBase	= weather->Temperature(pos2f.x, pos2f.y);

		float rain			= rainBase;
		float sun			= sunBase;
		float temperature	= temperatureBase;
		float growth		= 1.0f;

		Vector2I tap = pos2i + lightTap;

		// Check for something between us and the light.
		const WorldGrid& wgTap = worldMap->GetWorldGrid(tap);
		float tapHeight = float(wgTap.RockHeight());
		if (wgTap.PlantStage()) {
			tapHeight = PlantScript::PlantRes(wgTap.Plant() - 1, wgTap.PlantStage())->AABB().SizeY();
		}

		if (tapHeight > (height + 0.1f)) {
			// in shade
			sun *= SHADE_EFFECT;
			temperature *= SHADE_EFFECT;
		}

		// ---- Adjacent --- //
		static const int NADJ = 4;
		static const Vector2I check[NADJ] = { { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 } };
		int same = 0;
		for (int i = 0; i<NADJ; ++i) {
			tap = pos2i + check[i];
			const WorldGrid& wgAdj = worldMap->GetWorldGrid(tap.x, tap.y);
			if (wgAdj.Plant() == wg.Plant()) {
				++same;
			}

			if (wgAdj.RockHeight()) {
				// Water or rock runoff increase water.
				rain += 0.25f * rainBase;
			}
			if (wgAdj.IsFluid()) {
				rain += 0.25f;	// just a lot of water.
			}
			if (wgAdj.IsWater()) {
				rain += 0.25f;	// more water
				temperature = Mean(0.5f, temperature); // moderate temperature
			}
		}
		// Nutrient depletion? Too packed in?
		if (same == NADJ) {
			growth *= 0.25f;
		}

		// Are we under water?
		float fluidHeight = wg.FluidHeight();
		if (fluidHeight > 0.01f) {
			// Any amount of water goes to rain 100%
			rain = 1.0f;
			// not sure what to do with temp...assume a little cooler?
			temperature *= 0.8f;

			// blocks light...
			float sizeY = PlantScript::PlantRes(wg.Plant() - 1, wg.PlantStage())->AABB().SizeY();
			if (fluidHeight > sizeY)
				sun = 0;
			else if (fluidHeight > sizeY * 0.5f)
				sun = sun * (1.0f - fluidHeight / sizeY);
		}

		rain = Clamp(rain, 0.0f, 1.0f);
		temperature = Clamp(temperature, 0.0f, 1.0f);
		sun = Clamp(sun, 0.0f, 1.0f);

		// ------- calc ------- //
		Vector3F actual = { sun, rain, temperature };
		Vector3F optimal = { 0.5f, 0.5f, 0.5f };

		const GameItem* item = PlantScript::PlantDef(wg.Plant() - 1);
		item->keyValues.Get(ISC::sun, &optimal.x);
		item->keyValues.Get(ISC::rain, &optimal.y);
		item->keyValues.Get(ISC::temp, &optimal.z);

		float distance = (optimal - actual).Length();
		distance = distance / growth;

		const float GROW = Lerp(0.2f, 0.1f, (float)wg.PlantStage() / (float)(MAX_PLANT_STAGES - 1));
		const float DIE = 0.4f;
		float seconds = float(DELTA) / 1000.0f;

		if (distance < GROW) {
			// Heal.
			float hp = HP_PER_SECOND*seconds;
			DamageDesc heal( -hp, 0 );
			worldMap->VoxelHit(pos2i, heal);

			// Grow
			int nStage = wg.IsFlower() ? PLANT_BLOCKING_STAGE : MAX_PLANT_STAGES;

			if (wg.HPFraction() > 0.8f) {
				if (wg.PlantStage() < (nStage - 1)) {
					int hp = wg.HP();
					worldMap->SetPlant(pos2i.x, pos2i.y, wg.Plant(), wg.PlantStage() + 1);
					worldMap->SetWorldGridHP(pos2i.x, pos2i.y, hp);
				}
				if (random.Rand(GROWTH_CHANCE) < wg.PlantStage()) {
					// Number range reflects wind direction.
					int dx = -1 + random.Rand(4);	// [-1,2]
					int dy = -1 + random.Rand(3);	// [-1,1]

					// Remember that create plant will favor creating
					// existing plants, so we don't need to specify
					// what to create.
					Sim* sim = context->chitBag->GetSim();
					GLASSERT(sim);
					sim->CreatePlant(pos2i.x + dx, pos2i.y + dy, -1);
				}
			}
			int stage = wg.PlantStage();	// 0-3
			CoreScript* cs = CoreScript::GetCore(ToSector(pos2i));
			// Totally "what feels right in world gen" constant in the random.Rand()
			if ((census->wildFruit < MAX_WILD_FRUIT) && cs && (!cs->InUse()) && int(random.Rand(200)) < (stage*stage)) {
				context->chitBag->NewWildFruit(pos2i);
			}
		}
		else if (distance > DIE) {
			DamageDesc dd(HP_PER_SECOND * seconds, 0);
			worldMap->VoxelHit(pos2i, dd);
			if (wg.HP() == 0) {
				worldMap->SetPlant(pos2i.x, pos2i.y, 0, 0);
			}
		}
	}
}
Beispiel #10
0
void Weather::setFrom(Weather other){
  this->_pNoon=other.pNoon();
  this->_weatherType=other.weatherType();
  this->_lightning=other.lightning();
}
Beispiel #11
0
int main ()
{
    Weather *ww = new Weather(CITYID_GET_URL);
    int errInfo = ww->GetWeatherInfo(WeatherInfoURL_CountryCenter, AirQualityInfoURL_Xiaomi);
    cout << "main::" << endl;

    cout << ww->GetCity(0) << "  ";
    cout << ww->GetCity(1) << "  ";

    int time = 23;
    if ((time < 18) && (time > 7))
        cout << ww->GetImgNo(0) << "  ";
    else
        cout << ww->GetImgNo(1) << "  ";
    if (ww->GetImgNo(1) >= ImgNO_UnDef)
        cout << ImgNO_UnDef << "  ";

    cout << ww->GetTemp() << "  ";
    cout << ww->GetWeather() << "  ";

    cout << ww->GetAQI() << "  ";
    cout << ww->GetPM10() << "  ";
    cout << ww->GetPM25() << "  ";
    cout << ww->GetNO2() << "  ";
    cout << ww->GetSO2() << "  ";

    cout << endl;

    std::string errCode;
    if (errInfo & 1) { // get cityID error
        errCode = ERROR_GET_CITYID;
        cout << "error get city id..." << errCode << endl;
    } else {
        if (errInfo & (1 << 1)) { // get weather info error
            errCode = ERROR_GET_WEATHER;
            cout << "error get city id..." << errCode << endl;
        }
        if (errInfo & (1 << 2)) { // get aqi info error
            errCode = ERROR_GET_AQI;
            cout << "error get city id..." << errCode << endl;
        }
    }

#if TEST_HttpGet
    std::string content = HttpGet00(WeatherInfoBACKURL_CountryCenter);
    cout << "main:" << content << endl;
#endif
    return 0;
}
Beispiel #12
0
void Game::DoTick()
{
	// Tutorial 3: Walk the meteor list.
	// This looks really clunky to me...there's probably a better way.
	// Just be careful not to delete the iterator you are using.

	std::list< Meteor* >::iterator it = meteorList.begin();
	while ( it != meteorList.end() )
	{
		Meteor* meteor = *it;
		if ( meteor->Done() )
		{
			std::list< Meteor* >::iterator deleteIt = it;
			++it;
			meteorList.erase( deleteIt );
			delete meteor;
		}
		else
		{
			meteor->DoTick();
			++it;
		}
	}
	// Tutorial 4: Weather
	U32 day, hour, minute, second;
	Lilith3D::GetTimeClock()->CalcCalendarTime( &day, &hour, &minute, &second );
	Weather* weather = lilith->GetTargetWeather();

	// This is just so we don't keep calling this withou
	// significant time change. Look for the 'minute' in
	// game time to actually be different.
	if ( weatherMinute != minute )
	{
		const float FOG_MAX = 0.7f;
		const U32 FOG_START = 2;
		const U32 FOG_PEAK = 7;
		const U32 FOG_END = 11;
		const int RAIN_START = 16;
		const int RAIN_PEAK = 20;
		const int RAIN_END = 23;

		if ( hour >= FOG_START && hour <= FOG_END )
		{
			// Fog in the morning.
			if ( hour < FOG_PEAK )
				weather->SetFog( FOG_MAX * Interpolate( (float)FOG_START*60, (float)0.0f,
														  (float)FOG_PEAK*60, (float)1.0,
														  (float)(hour*60+minute) ) );
			else
				weather->SetFog( FOG_MAX * Interpolate( (float)FOG_PEAK*60, (float)1.0f,
														  (float)FOG_END*60, (float)0.0,
														  (float)(hour*60+minute) ) );
		}
		else if ( hour >= RAIN_START && hour <= RAIN_END )
		{
			// Rain in the evening - be sure to set a little fog too. Rain
			// looks bad without fog.		
			if ( hour < RAIN_PEAK )
			{
				weather->SetRain( Interpolate( (float)RAIN_START*60, (float)0.0f,
												 (float)RAIN_PEAK*60, (float)1.0,
												 (float)(hour*60+minute) ) );
				weather->SetFog( 0.5f * Interpolate( (float)RAIN_START*60, (float)0.0f,
													   (float)RAIN_PEAK*60, (float)1.0,
													   (float)(hour*60+minute) ) );
			}
			else
			{
				weather->SetRain( Interpolate( (float)RAIN_PEAK*60, (float)1.0f,
												 (float)RAIN_END*60, (float)0.0,
												 (float)(hour*60+minute) ) );
				weather->SetFog( 0.5f * Interpolate( (float)RAIN_PEAK*60, (float)1.0f,
													   (float)RAIN_END*60, (float)0.0,
													   (float)(hour*60+minute) ) );
			}
		}
		else
		{
			weather->SetRain( 0.0f );
			weather->SetFog( 0.0f );
		}
	}

}
Beispiel #13
0
void
PetPM::tick (const Time&, const Weather& weather, const double Rn, 
	     const Vegetation& crops,
	     const Surface& surface, const Geometry& geo,
             const Soil& soil,
	     const SoilHeat& soil_heat, const SoilWater& soil_water,
	     Treelog& msg)
{
  // Weather.

  const double Temp = weather.air_temperature ();
  const double VaporPressure = weather.vapor_pressure ();
  const double U2 = weather.wind ();
  const double AtmPressure = weather.air_pressure ();
  const double Cloudiness = weather.cloudiness ();
  
  // Ground heat flux.
  const double G = soil_heat.top_flux (geo, soil, soil_water);

  const double LAI = crops.LAI ();
  if (LAI > 0.0)
    {
      const double CropHeight = 0.01 * crops.height (); //cm -> m
      const double ScreenHeight = weather.screen_height ();

      // Dry.
      reference_evapotranspiration_dry
	= FAO::PenmanMonteith (CropHeight, ScreenHeight, 
                               LAI, crops.rs_min (),
                               Rn, G, Temp, VaporPressure,
                               U2, AtmPressure) * 3600;
      potential_evapotranspiration_dry
	= std::max (0.0, reference_evapotranspiration_dry);

      // Wet.
      reference_evapotranspiration_wet
	= FAO::PenmanMonteith (CropHeight, ScreenHeight, 
                               LAI, 0.0, Rn, G, Temp, VaporPressure,
                               U2, AtmPressure) * 3600;
      potential_evapotranspiration_wet
	= std::max (0.0, reference_evapotranspiration_wet);
    }
  else
    {
      const double Si = weather.global_radiation ();

      // Use reference crop as fallback for bare soil.
      const double ref_albedo = 0.23;
      net_radiation->tick (Cloudiness, Temp, VaporPressure, Si, ref_albedo, 
                           msg);
      const double ref_Rn = net_radiation->net_radiation ();
      
      reference_evapotranspiration_dry
	= FAO::RefPenmanMonteith (ref_Rn, G, Temp, VaporPressure, U2,
				  AtmPressure)
	* 3600;

      potential_evapotranspiration_dry
	= reference_to_potential_dry (crops, surface,
                                      reference_evapotranspiration_dry);

      reference_evapotranspiration_wet
	= FAO::RefPenmanMonteithWet (ref_Rn, G, Temp, VaporPressure, U2,
                                     AtmPressure, rb)
	* 3600;
      potential_evapotranspiration_wet
	= reference_to_potential_wet (crops, surface,
                                      reference_evapotranspiration_wet);
    }
}
Beispiel #14
0
CommandBarNewUI::CommandBarNewUI(Game *g) : CommandBar()
{
    game = g;
    background = NULL;
    Weather *weather;
    uint16 x_off = game->get_game_x_offset();
    uint16 y_off = game->get_game_y_offset();

    icon_w = 5;
    icon_h = 3;
	uint8 text_height;
	uint16 map_width;
	uint16 map_height;

	offset = OBJLIST_OFFSET_U6_COMMAND_BAR;

	if(game->get_game_type() == NUVIE_GAME_U6)
	{
		num_icons = table_size_U6;
		for (uint8 i = 0; i < table_size_U6; i++)
			mode_name_tbl[i] = U6_mode_name_tbl[i];
	}
	else if(game->get_game_type() == NUVIE_GAME_SE)
	{
		num_icons = table_size_SE;
		for (uint8 i = 0; i < table_size_SE; i++)
			mode_name_tbl[i] = SE_mode_name_tbl[i];
	}
	else // MD
	{
		num_icons = table_size_MD;
		for (uint8 i = 0; i < table_size_MD; i++)
			mode_name_tbl[i] = MD_mode_name_tbl[i];
	}

	if(game->is_orig_style())
	{
		text_height = 8;
		icon_y_offset = 0;
		map_width = 176;
		map_height = 176;
	}
	else
	{
		if(game->get_game_type() == NUVIE_GAME_U6)
		{
			text_height = 17;
			icon_y_offset = 9;
		} else {
			text_height = 8;
			icon_y_offset = 0;
		}
		if(game->is_original_plus())
			map_width = game->get_game_width() - game->get_background()->get_border_width();
		else
			map_width = game->get_game_width();
		map_height = game->get_game_height();
	}
	uint8 command_width = btn_size * icon_w;
	uint8 command_height = btn_size * icon_h + text_height;

	Init(NULL, (map_width - command_width)/2 + x_off, (map_height - command_height)/2 + y_off, 0, 0);
	area.w = command_width; // space for 5x3 icons
	area.h = command_height;

    event = NULL; // it's not set yet
    
    weather = game->get_weather();
    
    selected_action = -1;
    combat_mode = false;
    wind = weather->get_wind_dir_str();

    bg_color = game->get_palette()->get_bg_color();

        init_buttons();
    if(game->get_game_type() == NUVIE_GAME_U6 && !game->is_orig_style())
        weather->add_wind_change_notification_callback((CallBack *)this); //we want to know when the wind direction changes.

    cur_pos = 0;

    font = game->get_font_manager()->get_conv_font();
}
void getWeather()
{
    // Measure Relative Humidity from the HTU21D or Si7021
    humidity = sensor.getRH();

    // Measure Temperature from the HTU21D or Si7021
    tempf = sensor.getTempF();

    //
    // Temperature is measured every time RH is requested.
    // It is faster, therefore, to read it from previous RH
    // measurement with getTemp() instead with readTemp()
    //

    // Measure the Barometer temperature in F from the MPL3115A2
    baroTemp = sensor.readBaroTempF();

    // Measure Pressure from the MPL3115A2
    pascals = sensor.readPressure();

    // If in altitude mode, you can get a reading in feet  with this line:
    //altf = sensor.readAltitudeFt();

    getSoilTemp(); // Read the DS18B20 waterproof temp sensor
    getSoilMositure(); // Read the soil moisture sensor

    // Calc winddir
    winddir = get_wind_direction();

    // Calc windspeed
    windspeedmph = get_wind_speed();

    // Calc windgustmph
    // Calc windgustdir
    // Report the largest windgust today
    windgustmph = 0;
    windgustdir = 0;

    // Calc windspdmph_avg2m
    float temp = 0;

    for(int i = 0 ; i < 120 ; i++) {
      temp += windspdavg[i];
    }

    temp /= 120.0;
    windspdmph_avg2m = temp;

    // Calc winddir_avg2m
    temp = 0; // Can't use winddir_avg2m because it's an int

    for(int i = 0 ; i < 120 ; i++) {
      temp += winddiravg[i];
    }

    temp /= 120;
    winddir_avg2m = temp;

    //
    // Calc windgustmph_10m
    // Calc windgustdir_10m
    // Find the largest windgust in the last 10 minutes
    //
    windgustmph_10m = 0;
    windgustdir_10m = 0;

    // Step through the 10 minutes
    for(int i = 0; i < 10 ; i++)
    {
      if(windgust_10m[i] > windgustmph_10m)
      {
        windgustmph_10m = windgust_10m[i];
        windgustdir_10m = windgustdirection_10m[i];
      }
    }

    //
    // Total rainfall for the day is calculated within the interrupt
    // Calculate amount of rainfall for the last 60 minutes
    //
    rainin = 0;

    for(int i = 0 ; i < 60 ; i++) {
      rainin += rainHour[i];
    }
}
Beispiel #16
0
double 
Movement1D::bottom_heat (const Time& time, const Weather& weather) const 
{ return weather.T_normal (time, delay); }