本文整理汇总了C++中Weather类的典型用法代码示例。如果您正苦于以下问题:C++ Weather类的具体用法?C++ Weather怎么用?C++ Weather使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Weather类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Weather w;
w.show();
return a.exec();
}
开发者ID:lee820,项目名称:weatheForecast,代码行数:8,代码来源:main.cpp
示例2: AddWeather
/// 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;
}
开发者ID:kemlg,项目名称:trinitycore-conciens,代码行数:16,代码来源:WeatherMgr.cpp
示例3: SetBodyText
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());
}
开发者ID:csioza,项目名称:alteraorbis,代码行数:47,代码来源:startwidget.cpp
示例4: RunWeather
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;
}
开发者ID:garybuhrmaster,项目名称:mythtv,代码行数:17,代码来源:main.cpp
示例5: display_surface_strip
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;
}
开发者ID:nuvie,项目名称:nuvie,代码行数:21,代码来源:SunMoonStripWidget.cpp
示例6: JSONwCheck
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, "}");
}
开发者ID:egisz,项目名称:sprinklers_pi,代码行数:24,代码来源:web.cpp
示例7: DoTick
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;
//.........这里部分代码省略.........
开发者ID:fordream,项目名称:alteraorbis,代码行数:101,代码来源:plantscript.cpp
示例8: setFrom
void Weather::setFrom(Weather other){
this->_pNoon=other.pNoon();
this->_weatherType=other.weatherType();
this->_lightning=other.lightning();
}
开发者ID:ArthurMaker,项目名称:tempescope,代码行数:5,代码来源:Weather.cpp
示例9: main
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;
}
开发者ID:github188,项目名称:SimpleCode,代码行数:49,代码来源:WeatherMain.cpp
示例10: while
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 );
}
}
}
开发者ID:gefariasjr,项目名称:projetofinal1,代码行数:84,代码来源:tutorial5.cpp
示例11:
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);
}
}
开发者ID:pamoakoy,项目名称:daisy-model,代码行数:70,代码来源:pet_PM.C
示例12: CommandBar
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();
}
开发者ID:Zabeus,项目名称:nuvie,代码行数:83,代码来源:CommandBarNewUI.cpp
示例13: getWeather
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];
}
}
开发者ID:menloparkinnovation,项目名称:openpux,代码行数:86,代码来源:SparkFun_Photon_Weather_Menlo.cpp
示例14:
double
Movement1D::bottom_heat (const Time& time, const Weather& weather) const
{ return weather.T_normal (time, delay); }
开发者ID:pamoakoy,项目名称:daisy-model,代码行数:3,代码来源:movement_1D.C
示例15: Hardware_Initialize
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;
}
开发者ID:menloparkinnovation,项目名称:openpux,代码行数:49,代码来源:SparkFun_Photon_Weather_Menlo.cpp
注:本文中的Weather类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论