// ------------------------------------------------------------------------------------------------ void ProjectileBase :: Update(float timeDelta) { // Pre-Conditions: assert(IsActive() && "ProjectileBase::Update IsActive()"); if(IsActive()) { updateEvent->Process(this); if(isMoving) { Vector2df nextPos = Pos() + Heading() * speed * timeDelta; if(Game()->CheckCollisionWithChars(nextPos + Heading() * radius)) { hitPos = nextPos + Heading() * radius; hitCharEvent->Process(this); } if(Game()->IsPosSolid(nextPos + Heading() * radius)) { hitPos = nextPos + Heading() * radius; hitSolidEvent->Process(this); } SetPos(nextPos); } DecreaseLife(timeDelta); } // Post-Conditions assert(Pos().x >= MAP_MIN_POS_X && Pos().x < MAP_MAX_POS_X && "ProjectileBase::Update Pos().x >= MAP_MIN_POS_X && Pos().x < MAP_MAX_POS_X"); assert(Pos().y >= MAP_MIN_POS_Y && Pos().y < MAP_MAX_POS_Y && "ProjectileBase::Update Pos().y >= MAP_MIN_POS_Y && Pos().y < MAP_MAX_POS_Y"); } // ----------------------------------------------------------------------------------------------
void CUIWeaponCellItem::Update() { bool b = Heading(); inherited::Update (); bool bForceReInitAddons = (b!=Heading()); if (object()->SilencerAttachable()) { if (object()->IsSilencerAttached()) { if (!GetIcon(eSilencer) || bForceReInitAddons) { CreateIcon (eSilencer); InitAddon (GetIcon(eSilencer), *object()->GetSilencerName(), m_addon_offset[eSilencer], Heading()); } } else { if (m_addons[eSilencer]) DestroyIcon(eSilencer); } } if (object()->ScopeAttachable()){ if (object()->IsScopeAttached()) { if (!GetIcon(eScope) || bForceReInitAddons) { CreateIcon (eScope); InitAddon (GetIcon(eScope), *object()->GetScopeName(), m_addon_offset[eScope], Heading()); } } else { if (m_addons[eScope]) DestroyIcon(eScope); } } if (object()->GrenadeLauncherAttachable()){ if (object()->IsGrenadeLauncherAttached()) { if (!GetIcon(eLauncher) || bForceReInitAddons) { CreateIcon (eLauncher); InitAddon (GetIcon(eLauncher), *object()->GetGrenadeLauncherName(), m_addon_offset[eLauncher], Heading()); } } else { if (m_addons[eLauncher]) DestroyIcon(eLauncher); } } }
Dialogs::ConvertMemoryCardDialog::ConvertMemoryCardDialog( wxWindow* parent, const wxDirName& mcdPath, const AppConfig::McdOptions& mcdSourceConfig ) : wxDialogWithHelpers( parent, _( "Convert a memory card to a different format" ) ) , m_mcdPath( mcdPath ) , m_mcdSourceFilename( mcdSourceConfig.Filename.GetFullName() ) { SetMinWidth( 472 * MSW_GetDPIScale()); CreateControls( mcdSourceConfig.Type ); if ( m_radio_CardType ) m_radio_CardType->Realize(); wxBoxSizer& s_buttons( *new wxBoxSizer( wxHORIZONTAL ) ); s_buttons += new wxButton( this, wxID_OK, _( "Convert" ) ) | pxProportion( 2 ); s_buttons += pxStretchSpacer( 3 ); s_buttons += new wxButton( this, wxID_CANCEL ) | pxProportion( 2 ); wxBoxSizer& s_padding( *new wxBoxSizer( wxVERTICAL ) ); s_padding += Heading( wxString( _( "Convert: " ) ) + ( mcdPath + m_mcdSourceFilename ).GetFullPath() ).Unwrapped() | pxSizerFlags::StdExpand(); wxBoxSizer& s_filename( *new wxBoxSizer( wxHORIZONTAL ) ); s_filename += Heading( _( "To: " ) ).Unwrapped().Align(wxALIGN_RIGHT) | pxProportion(1); m_text_filenameInput->SetValue( wxFileName( m_mcdSourceFilename ).GetName() + L"_converted" ); s_filename += m_text_filenameInput | pxProportion(2); s_filename += Heading( L".ps2" ).Align(wxALIGN_LEFT) | pxProportion(1); s_padding += s_filename | pxSizerFlags::StdExpand(); s_padding += m_radio_CardType | pxSizerFlags::StdExpand(); if ( mcdSourceConfig.Type != MemoryCardType::MemoryCard_File ) { s_padding += Heading( pxE( L"Please note that the resulting file may not actually contain all saves, depending on how many are in the source memory card." ) ); } s_padding += Heading( pxE( L"WARNING: Converting a memory card may take a while! Please do not close the emulator during the conversion process, even if the emulator is no longer responding to input." ) ); s_padding += 12; s_padding += s_buttons | pxSizerFlags::StdCenter(); *this += s_padding | pxSizerFlags::StdExpand(); Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( ConvertMemoryCardDialog::OnOk_Click ) ); Connect( m_text_filenameInput->GetId(), wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( ConvertMemoryCardDialog::OnOk_Click ) ); SetSizerAndFit(GetSizer()); m_text_filenameInput->SetFocus(); m_text_filenameInput->SelectAll(); }
void main(void) { Sys_Init(); //All init function putchar(' '); XBR0_Init(); ADC_Init(); Port_Init(); PCA_Init(); SMB_Init(); //end the init function lcd_clear(); lcd_print("initializing\r\n"); printf("\n\n\n\rinitalizing"); PCA0CP2 = 0xFFFF - MOTOR_NEUT;//set all to neutural PCA0CPL0 = 0xFFFF - PW_CENTER; PCA0CPH0 = (0xFFFF - PW_CENTER) >> 8; pause(); //pause for a second? start_run(); while (1) { while(SS){ // if the slideswitch is off slide_switch_off(); }///end slide switch off while(!SS){ //while the slideswitch is on Heading(); Ranger(); LCD_Print(); //print all values on the lcd printf("\n\rRange:%d Compass:%d dh: %d, mPW: %d, sPW %d, batt:%d, obst: %d", range, heading, desired_heading, MOTOR_PW_AND_STEER_PW, STEER_PW, battery, near_obstical); //print these on the secure crt for data aquisition //printf("\n\r Range:%d Compass:%d dh: %d, mPW: %d, sPW %d, obst: %d", range, heading, desired_heading, MOTOR_PW_AND_STEER_PW, STEER_PW, near_obstical); //print these on the secure crt for data aquisition }//end slide switch on } //end of the infinite while loop }//end of the main function
//------------------------------ Update --------------------------------------- //----------------------------------------------------------------------------- void Rocket::Update() { if (!m_bImpacted) { m_vVelocity = MaxSpeed() * Heading(); //make sure vehicle does not exceed maximum velocity m_vVelocity.Truncate(m_dMaxSpeed); //update the position m_vPosition += m_vVelocity; TestForImpact(); } else { m_dCurrentBlastRadius += script->GetDouble("Rocket_ExplosionDecayRate"); //when the rendered blast circle becomes equal in size to the blast radius //the rocket can be removed from the game if (m_dCurrentBlastRadius > m_dBlastRadius) { m_bDead = true; } } }
void CUICellItem::Update() { if (m_pParentList) EnableHeading(m_pParentList->GetVerticalPlacement()); if(Heading()) { SetHeading ( 90.0f * (PI/180.0f) ); SetHeadingPivot (Fvector2().set(0.0f,0.0f), Fvector2().set(0.0f,GetWndSize().y), true); }else ResetHeadingPivot (); inherited::Update(); if ( CursorOverWindow() ) { Frect clientArea; m_pParentList->GetClientArea(clientArea); Fvector2 cp = GetUICursor()->GetCursorPosition(); if(clientArea.in(cp)) GetMessageTarget()->SendMessage(this, DRAG_DROP_ITEM_FOCUSED_UPDATE, NULL); } m_b_already_drawn=false; }
CUIDragItem* CUICellItem::CreateDragItem() { CUIDragItem* tmp; tmp = xr_new<CUIDragItem>(this); Frect r; GetAbsoluteRect(r); if( m_UIStaticItem.GetFixedLTWhileHeading() ) { float w, h; w = r.width(); h = r.height(); if (Heading()) { // исправление пропорций w = w / m_cell_size.x * m_cell_size.y; h = h / m_cell_size.y * m_cell_size.x; } Fvector2 cp = GetUICursor()->GetCursorPosition(); // поворот на 90 градусов, и центрирование по курсору мыша r.x1 = (cp.x - h / 2.0f); r.y1 = (cp.y - w / 2.0f); r.x2 = r.x1 + h; r.y2 = r.y1 + w; } tmp->Init(GetShader(),r,GetUIStaticItem().GetOriginalRect()); return tmp; }
void main(void) { Sys_Init(); //All init function putchar(' '); XBR0_Init(); ADC_Init(); Port_Init(); PCA_Init(); SMB_Init(); //end the init function lcd_clear(); lcd_print("initializing\r\n"); PCA0CP2 = 0xFFFF - MOTOR_NEUT; PCA0CPL0 = 0xFFFF - PW_CENTER; PCA0CPH0 = (0xFFFF - PW_CENTER) >> 8; while (n_Counts < 50); //pause for a second? start_run(); while (1) { while(SS){ // if the slideswitch is off slide_switch_off(); }///end slide switch off while(!SS) //while the slideswitch is on { Heading(); Ranger(); LCD_Print(); //print all values on the lcd printf("\n\r Range:%d Compass:%d PW:%d", range, heading, PW); //print these on the secure crt for data aquisition } } //end of the infinite while loop }//end of the main function
void CUIButton::DrawTexture() { Frect rect; GetAbsoluteRect (rect); if(m_bAvailableTexture && m_bTextureEnable) { if(m_eButtonState == BUTTON_UP || m_eButtonState == BUTTON_NORMAL) m_UIStaticItem.SetPos(rect.left + m_TextureOffset.x, rect.top + m_TextureOffset.y); else m_UIStaticItem.SetPos(rect.left + m_PushOffset.x + m_TextureOffset.x, rect.top + m_PushOffset.y + m_TextureOffset.y); if(m_bStretchTexture) m_UIStaticItem.SetRect(0, 0, rect.width(), rect.height()); else { Frect r={0,0, m_UIStaticItem.GetOriginalRectScaled().width(), m_UIStaticItem.GetOriginalRectScaled().height()}; m_UIStaticItem.SetRect(r); } if( Heading() ) m_UIStaticItem.Render( GetHeading() ); else m_UIStaticItem.Render(); } }
//------------------------------ Update --------------------------------------- //----------------------------------------------------------------------------- void Bolt::Update() { if (!m_bImpacted) { m_vVelocity = MaxSpeed() * Heading(); //make sure vehicle does not exceed maximum velocity m_vVelocity.Truncate(m_dMaxSpeed); //update the position m_vPosition += m_vVelocity; //if the projectile has reached the target position or it hits an entity //or wall it should explode/inflict damage/whatever and then mark itself //as dead //test to see if the line segment connecting the bolt's current position //and previous position intersects with any bots. Raven_Bot* hit = GetClosestIntersectingBot(m_vPosition - m_vVelocity, m_vPosition); //if hit if (hit) { m_bImpacted = true; m_bDead = true; //send a message to the bot to let it know it's been hit, and who the //shot came from Dispatcher->DispatchMsg(SEND_MSG_IMMEDIATELY, m_iShooterID, hit->ID(), Msg_TakeThatMF, (void*)&m_iDamageInflicted); } //test for impact with a wall double dist; if( FindClosestPointOfIntersectionWithWalls(m_vPosition - m_vVelocity, m_vPosition, dist, m_vImpactPoint, m_pWorld->GetMap()->GetWalls())) { m_bDead = true; m_bImpacted = true; m_vPosition = m_vImpactPoint; return; } } }
void GlobalReference::reset() { position_ = Position(); heading_ = Heading(); has_position_ = false; has_heading_ = false; has_altitude_ = false; updated(); }
void CUIWeaponCellItem::InitAddon(CUIStatic* s, LPCSTR section, Fvector2 addon_offset, bool b_rotate) { Frect tex_rect; Fvector2 base_scale; if(Heading()) { base_scale.x = GetHeight()/(INV_GRID_WIDTHF*m_grid_size.x); base_scale.y = GetWidth()/(INV_GRID_HEIGHTF*m_grid_size.y); }else { base_scale.x = GetWidth()/(INV_GRID_WIDTHF*m_grid_size.x); base_scale.y = GetHeight()/(INV_GRID_HEIGHTF*m_grid_size.y); } Fvector2 cell_size; cell_size.x = pSettings->r_u32(section, "inv_grid_width")*INV_GRID_WIDTHF; cell_size.y = pSettings->r_u32(section, "inv_grid_height")*INV_GRID_HEIGHTF; tex_rect.x1 = pSettings->r_u32(section, "inv_grid_x")*INV_GRID_WIDTHF; tex_rect.y1 = pSettings->r_u32(section, "inv_grid_y")*INV_GRID_HEIGHTF; tex_rect.rb.add (tex_rect.lt,cell_size); cell_size.mul (base_scale); if(b_rotate) { s->SetWndSize (Fvector2().set(cell_size.y, cell_size.x) ); Fvector2 new_offset; new_offset.x = addon_offset.y*base_scale.x; new_offset.y = GetHeight() - addon_offset.x*base_scale.x - cell_size.x; addon_offset = new_offset; }else { s->SetWndSize (cell_size); addon_offset.mul (base_scale); } s->SetWndPos (addon_offset); s->SetOriginalRect (tex_rect); s->SetStretchTexture (true); s->EnableHeading (b_rotate); if(b_rotate) { s->SetHeading (GetHeading()); Fvector2 offs; offs.set (0.0f, s->GetWndSize().y); s->SetHeadingPivot (Fvector2().set(0.0f,0.0f), /*Fvector2().set(0.0f,0.0f)*/offs, true); } }
//=============================================== //処理 //=============================================== //[input] // なし //[return] // なし //=============================================== void CField::Exec() { //::D3DXVec3TransformCoord(&vAxisX, &vAxisX, &m_matRotate); //::D3DXVec3TransformCoord(&vAxisZ, &vAxisZ, &m_matRotate); //if(CJoyPad::GetState(0, PAD_STATE_HOLD, PAD_DIR_LEFT) ) //{ // m_vPos -= vAxisX*0.1f; // //m_Anim += 1.0f; //} // //if(CJoyPad::GetState(0, PAD_STATE_HOLD, PAD_DIR_RIGHT) ) //{ // m_vPos += vAxisX*0.1f; // //m_Anim += 1.0f; //} // //if(CJoyPad::GetState(0, PAD_STATE_HOLD, PAD_DIR_UP) ) //{ // m_vPos -= vAxisZ * 0.1f; // //m_vPos.z -= 0.1f; // //m_Anim += 1.0f; //} // //if(CJoyPad::GetState(0, PAD_STATE_HOLD, PAD_DIR_DOWN) ) //{ // m_vPos += vAxisZ * 0.1f; // //m_vPos.z += 0.1f; // //m_Anim += 1.0f; //} //if(CJoyPad::GetState(0, PAD_STATE_HOLD, PAD_BUTTON_02) ) //{ // m_vRot.x += 0.1f; //} // Update(0.000f); Translation(m_vPos.x, m_vPos.y, m_vPos.z); Scaling(m_vScale.x, m_vScale.y, m_vScale.z); Heading(m_vRot.x); Pitching(m_vRot.x); Rolling(m_vRot.x); Render(Joker::GetDevice()); SetWorldMatrix(); }
static void calculate_compass() { int magX = 0; int magY = 0; int magZ = 0; static int count = 0; int iResult; int offsets[3] = {0}; double dHeading = 0; float accForward; float accLeft; orietation_data[0] = gsensor_data[0]; orietation_data[1] = gsensor_data[1]; orietation_data[2] = gsensor_data[2]; compass_data[0] = g_compass_data.y; compass_data[1] = -g_compass_data.x; compass_data[2] = g_compass_data.z; magX = compass_data[0]; magY = compass_data[1]; magZ = compass_data[2]; count++; if (count < 1200){ CollectDataItem(magX, magY, magZ); //LOGE("CollectData.\n"); } iResult = Calibrate(&offsets[0]); // Elsewhere in the application, getting magnetic data and correcting out the // hard iron disturbances magX -= offsets[0]; magY -= offsets[1]; magZ -= offsets[2]; //Magnetic field data is now ready to be used accForward = 0; accLeft = 0; dHeading = Heading(-magX,magY,magZ,accForward ,accLeft); if (dHeading >0) { // Use the Heading Value g_compass_data.x = dHeading; } Calculate_Sensor_Angle(); g_compass_data.y = sensor_angle[1]; g_compass_data.z = sensor_angle[2]; }
Fvector2 CUICustomMap::ConvertRealToLocal (const Fvector2& src)// meters->pixels (relatively own left-top pos) { Fvector2 res; if( !Heading() ){ return ConvertRealToLocalNoTransform(src); }else{ Fvector2 heading_pivot = GetStaticItem()->GetHeadingPivot(); res = ConvertRealToLocalNoTransform(src); res.sub(heading_pivot); rotation_(res.x, res.y, GetHeading(), res.x, res.y); res.add(heading_pivot); return res; }; }
void CUICellItem::Update() { if (m_pParentList) EnableHeading(m_pParentList->GetVerticalPlacement()); if(Heading()) { SetHeading ( 90.0f * (PI/180.0f) ); SetHeadingPivot (Fvector2().set(0.0f,0.0f), Fvector2().set(0.0f,GetWndSize().y), true); }else ResetHeadingPivot (); inherited::Update(); m_b_already_drawn=false; }
void cEntity::TakeDamage(eDamageType a_DamageType, cEntity * a_Attacker, int a_RawDamage, int a_FinalDamage, double a_KnockbackAmount) { TakeDamageInfo TDI; TDI.DamageType = a_DamageType; TDI.Attacker = a_Attacker; TDI.RawDamage = a_RawDamage; TDI.FinalDamage = a_FinalDamage; Vector3d Heading(0, 0, 0); if (a_Attacker != NULL) { Heading = a_Attacker->GetLookVector() * (a_Attacker->IsSprinting() ? 10 : 8); } Heading.y = 2; TDI.Knockback = Heading * a_KnockbackAmount; DoTakeDamage(TDI); }
bool Player::FireEnergyCannon(ItemInstance *item) { float pos[3]; float *_heading = Heading(); float range = (float)item->WeaponRange; if (GetEnergyValue() < item->EnergyUse) { SendVaMessage("Not enough energy! Need: %f", item->EnergyUse); return false; } /* Use the energy */ RemoveEnergy(item->EnergyUse); pos[0] = PosX() + ( range * _heading[0] ); pos[1] = PosY() + ( range * _heading[1] ); pos[2] = PosZ() + ( range * _heading[2] ); RangeListVec::iterator itrRList; Player *p = (0); while (g_PlayerMgr->GetNextPlayerOnList(p, m_RangeList)) { p->PointEffect(pos, 1017, 3.0f); //see if this player is in range of explosion. float range_to_blast = p->RangeFrom(pos, true); if (p != this) { SendVaMessage("Range to blast: %.2f", range_to_blast); } if (range_to_blast < 1000.0f) { float damage = p->CaughtInEnergyBlast(GameID(), range_to_blast); if (damage > 0) { SendVaMessage("Blast Damage: %.2f", damage); SendClientDamage(p->GameID(), GameID(), damage, 0, 0); } } } return true; }
bool DoCalculations(NMEA_INFO *Basic, DERIVED_INFO *Calculated) { // first thing: assign navaltitude! EnergyHeightNavAltitude(Basic, Calculated); // second thing: if available, get external wind precalculated! if ( (Basic->ExternalWindAvailable==TRUE) && (AutoWindMode==D_AUTOWIND_EXTERNAL)) { if (Basic->ExternalWindSpeed>0 && Basic->ExternalWindSpeed<35) { Calculated->WindSpeed = Basic->ExternalWindSpeed; Calculated->WindBearing = Basic->ExternalWindDirection; } } Heading(Basic, Calculated); DistanceToNext(Basic, Calculated); DistanceToHome(Basic, Calculated); DetectFreeFlying(Basic,Calculated); // check ongoing powerless flight DoLogging(Basic, Calculated); Vario(Basic,Calculated); TerrainHeight(Basic, Calculated); AltitudeRequired(Basic, Calculated, MACCREADY); DoAlternates(Basic,Calculated,TASKINDEX); if (IsMultiMapShared()) { DoAlternates(Basic,Calculated,RESWP_LASTTHERMAL); DoAlternates(Basic,Calculated,RESWP_TEAMMATE); DoAlternates(Basic,Calculated,RESWP_FLARMTARGET); DoAlternates(Basic,Calculated,HomeWaypoint); #ifdef GTL2 if (DoOptimizeRoute() || ACTIVE_WP_IS_AAT_AREA) DoAlternates(Basic, Calculated, RESWP_OPTIMIZED); #else if (DoOptimizeRoute()) DoAlternates(Basic,Calculated,RESWP_OPTIMIZED); #endif for (int i=RESWP_FIRST_MARKER; i<=RESWP_LAST_MARKER; i++) { if (WayPointList[i].Latitude==RESWP_INVALIDNUMBER) continue; DoAlternates(Basic,Calculated,i); } #ifndef GTL2 } #else } else {
void GlobalReference::updated() { // check if a non-default reference has been set if (position_.latitude != Position().latitude) has_position_ = true; if (position_.longitude != Position().longitude) has_position_ = true; if (position_.altitude != Position().altitude) has_altitude_ = true; if (heading_.value != Heading().value) has_heading_ = true; // WGS84 constants static const double equatorial_radius = 6378137.0; static const double flattening = 1.0/298.257223563; static const double excentrity2 = 2*flattening - flattening*flattening; // calculate earth radii double temp = 1.0 / (1.0 - excentrity2 * sin(position_.latitude) * sin(position_.latitude)); double prime_vertical_radius = equatorial_radius * sqrt(temp); radius_.north = prime_vertical_radius * (1 - excentrity2) * temp; radius_.east = prime_vertical_radius * cos(position_.latitude); // calculate sin and cos of the heading reference sincos(heading_.value, &heading_.sin, &heading_.cos); }
void ScanForFunctions(CLanguageProxy& proxy) { const char *text = proxy.Text(), *max = text + proxy.Size(); if (*max != 0) return; while (text < max) { text = skip(text, '<'); text = skip_white(text); switch (toupper(*text)) { case 0: return; case 'A': if (isspace(*++text)) text = Anchor(text, proxy); else text = skip_nc(text, '>'); break; case 'H': if (*++text >= '1' && *text <= '6') { text = Heading(text, proxy); } else text = skip_nc(text, '>'); break; case 'S': if (strncasecmp(text, "SCRIPT", 6) == 0) text = JavaScript(text, proxy); break; default: text = skip_nc(text + 1, '>'); break; } } } /* ScanForFunctions */
void CUICellItem::Update() { EnableHeading(m_pParentList->GetVerticalPlacement()); if(Heading()) { SetHeading ( 90.0f * (PI/180.0f) ); SetHeadingPivot (Fvector2().set(0.0f,0.0f), Fvector2().set(0.0f,GetWndSize().y), true); }else ResetHeadingPivot (); inherited::Update(); if ( CursorOverWindow() ) { Frect clientArea; m_pParentList->GetClientArea(clientArea); Fvector2 cp = GetUICursor().GetCursorPosition(); if(clientArea.in(cp)) GetMessageTarget()->SendMessage(this, DRAG_DROP_ITEM_FOCUSED_UPDATE, NULL); } PIItem item = (PIItem)m_pData; if ( item ) { m_has_upgrade = item->has_any_upgrades(); // Fvector2 size = GetWndSize(); // Fvector2 up_size = m_upgrade->GetWndSize(); // pos.x = size.x - up_size.x - 4.0f; Fvector2 pos; pos.set( m_upgrade_pos ); if ( ChildsCount() ) { pos.x += m_text->GetWndSize().x + 2.0f; } m_upgrade->SetWndPos( pos ); } m_upgrade->Show( m_has_upgrade ); }
VehicleState(Position pos = Position(), Speed s = Speed(), Heading h = Heading(), Acceleration a = Acceleration(), VehicleSize vsize = VehicleSize()) : position(pos), speed(s), heading(h), acceleration(a), size(vsize) {}
static Heading InRadians(double rad) { double deg = rad * 180 / cpp::math::PI; return Heading((int16_t)(deg/CF)); }
void FacilityShadingGridController::addColumns(const QString &category, std::vector<QString> & fields) { // always show name and selected columns // show type next to name, since it comes from the groups fields.insert(fields.begin(), { NAME, TYPE, SELECTED }); m_baseConcepts.clear(); for (const auto &field : fields) { if (field == NAME) { addNameLineEditColumn(Heading(QString(NAME), false, false), false, false, CastNullAdapter<model::ShadingSurfaceGroup>(&model::ShadingSurfaceGroup::name), CastNullAdapter<model::ShadingSurfaceGroup>(&model::ShadingSurfaceGroup::setName) ); } // Evan note: TODO to correctly use this column we need a new control -- // a dropzone for spaces, and a combo box with site and building as choices else if (field == TYPE) { std::function<std::vector<std::string>()> choices( []() { std::vector<std::string> choices{ "Site", "Building", "Space" }; return choices; } ); addComboBoxColumn(Heading(QString(TYPE)), std::function<std::string(const std::string &)>(static_cast<std::string(*)(const std::string&)>(&openstudio::toString)), choices, CastNullAdapter<model::ShadingSurfaceGroup>(&model::ShadingSurfaceGroup::shadingSurfaceType), CastNullAdapter<model::ShadingSurfaceGroup>(&model::ShadingSurfaceGroup::setShadingSurfaceType), boost::optional<std::function<void(model::ShadingSurfaceGroup*)>>(), boost::optional<std::function<bool(model::ShadingSurfaceGroup*)>>() ); } else { std::function<std::vector<model::ModelObject>(const model::ShadingSurfaceGroup &)> allShadingSurfaces( [](const model::ShadingSurfaceGroup &t_shadingSurfaceGroup) { std::vector<model::ModelObject> allModelObjects; auto shadingSurfaces = t_shadingSurfaceGroup.shadingSurfaces(); allModelObjects.insert(allModelObjects.end(), shadingSurfaces.begin(), shadingSurfaces.end()); return allModelObjects; } ); if (field == SELECTED) { auto checkbox = QSharedPointer<QCheckBox>(new QCheckBox()); checkbox->setToolTip("Check to select all rows"); connect(checkbox.data(), &QCheckBox::stateChanged, this, &FacilityShadingGridController::selectAllStateChanged); connect(checkbox.data(), &QCheckBox::stateChanged, this->gridView(), &OSGridView::gridRowSelectionChanged); addSelectColumn(Heading(QString(SELECTED), false, false, checkbox), "Check to select this row", DataSource( allShadingSurfaces, true ) ); } else if (field == SHADINGSURFACENAME) { addLoadNameColumn(Heading(QString(SHADINGSURFACENAME), true, false), CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::name), CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::setName), boost::optional<std::function<void(model::ShadingSurface *)>>( std::function<void(model::ShadingSurface *)>( [](model::ShadingSurface *t_ss) { t_ss->remove(); } ) ), DataSource( allShadingSurfaces, true ) ); } else if (field == CONSTRUCTIONNAME) { addDropZoneColumn(Heading(QString(CONSTRUCTIONNAME), true, false), CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::construction), CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::setConstruction), boost::optional<std::function<void(model::ShadingSurface*)> >(NullAdapter(&model::ShadingSurface::resetConstruction)), boost::optional<std::function<bool(model::ShadingSurface*)> >(NullAdapter(&model::ShadingSurface::isConstructionDefaulted)), DataSource( allShadingSurfaces, true ) ); } else if (field == TRANSMITTANCESCHEDULENAME) { std::function<bool(model::ShadingSurface *, const model::Schedule &)> setter( [](model::ShadingSurface *t_shadingSurface, const model::Schedule &t_schedule) { auto copy = t_schedule; return t_shadingSurface->setTransmittanceSchedule(copy); } ); addDropZoneColumn(Heading(QString(TRANSMITTANCESCHEDULENAME), true, false), CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::transmittanceSchedule), setter, boost::optional<std::function<void(model::ShadingSurface*)>>(CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::resetTransmittanceSchedule)), boost::optional<std::function<bool(model::ShadingSurface*)> >(), DataSource( allShadingSurfaces, true ) ); } else { // unhandled OS_ASSERT(false); } } } }
bool CXbowDriver::GetData() { //here we actually access serial ports etc if(m_pPort->IsStreaming()) { MOOSTrace("Crossbow must not be streaming\n"); return false; } //ask the crossbow for a reading m_pPort->Write("G",1); string sWhat; unsigned char Reply[CROSSBOW_POLLED_ANGLE_MODE_REPLY_LENGTH]; //note local call back invoked here to specify termination int nRead = m_pPort->ReadNWithTimeOut((char*)Reply,sizeof(Reply)); if(nRead == CROSSBOW_POLLED_ANGLE_MODE_REPLY_LENGTH) { if(Reply[0]!=255) { MOOSTrace("Unexpected Header in CrossBow reply\n"); } //angles short nRoll = (Reply[1]<<8) + Reply[2]; short nPitch = (Reply[3]<<8) + Reply[4]; short nYaw = (Reply[5]<<8) + Reply[6]; //This is roll, pitch and yaw for the DMU-AHRS, which is rotated //relative to the vehicle body. It has Z down and X out the tail. double df_deg_CBRoll = nRoll*180.0/pow(2.0,15.0); double df_deg_CBPitch = nPitch*180.0/pow(2.0,15.0); double df_deg_CBYaw = nYaw*180.0/pow(2.0,15.0); //account for alignment of crossbow in vehicle frame //this is the angle measured from the vehicle center line(y) double dfHeading = df_deg_CBYaw+m_dfVehicleYToINSX; //now correct for magnetic offset dfHeading+=m_dfMagneticOffset; //convert to Yaw.. //Notice that Heading is in DEGREES, positive CLOCKWISE //while Yaw is in RADIANS, positive COUNTERCLOCKWISE double dfYaw = -dfHeading*PI/180.0; dfYaw = MOOS_ANGLE_WRAP(dfYaw); //initialise transformed angles (in degrees) double df_deg_TRoll = df_deg_CBRoll; double df_deg_TPitch = df_deg_CBPitch; if( m_dfVehicleYToINSX == 0 ) { //Crossbow roll and vehicle body roll match. df_deg_TRoll = df_deg_TRoll; //same for Pitch. df_deg_TPitch = df_deg_TPitch; } else if (m_dfVehicleYToINSX == 180) { df_deg_TRoll = -df_deg_TRoll; df_deg_TPitch = -df_deg_TPitch; } else { MOOSTrace("Bad 'TWIST' value (use 0 or 180)!\r\n"); return false; } //look after pitch double dfPitch = MOOSDeg2Rad(df_deg_TPitch); //look after roll double dfRoll = MOOSDeg2Rad(df_deg_TRoll); //find the temperature every so often m_nTempCnt++; if((m_nTempCnt % 100) == 0) { short nTemp = ( Reply[25] << 8 ) + Reply[26]; m_dfTemp = 44.4 * ( ((double)nTemp * 5.0/4096.0) - 1.375); CMOOSMsg Temperature(MOOS_NOTIFY, "INS_TEMPERATURE", m_dfTemp); m_Notifications.push_back(Temperature); } //notify the MOOS CMOOSMsg Heading(MOOS_NOTIFY, "INS_HEADING", dfHeading); m_Notifications.push_back(Heading); CMOOSMsg Yaw(MOOS_NOTIFY, "INS_YAW", dfYaw); m_Notifications.push_back(Yaw); CMOOSMsg Pitch(MOOS_NOTIFY, "INS_PITCH", dfPitch); m_Notifications.push_back(Pitch); CMOOSMsg Roll(MOOS_NOTIFY, "INS_ROLL", dfRoll); m_Notifications.push_back(Roll); //rates short nRollRate = (Reply[7]<<8) + Reply[8];//p-dot short nPitchRate = (Reply[9]<<8) + Reply[10];//q-dot short nYawRate = (Reply[11]<<8) + Reply[12];//r-dot //xbow calib constant double RR = 100.0;//deg/sec double dfRollRate = nRollRate * RR * 1.5/pow(2.0,15); double dfPitchRate = nPitchRate * RR * 1.5/pow(2.0,15); double dfYawRate = nYawRate * RR * 1.5/pow(2.0,15); //note X and Y axes are switched CMOOSMsg RollRate(MOOS_NOTIFY, "INS_ROLLRATE_Y", dfRollRate); m_Notifications.push_back(RollRate); CMOOSMsg PitchRate(MOOS_NOTIFY, "INS_ROLLRATE_X", dfPitchRate); m_Notifications.push_back(PitchRate); CMOOSMsg YawRate(MOOS_NOTIFY, "INS_ROLLRATE_Z", dfYawRate); m_Notifications.push_back(YawRate); //accelerations short nXAccel = (Reply[13]<<8) + Reply[14];//v-dot short nYAccel = (Reply[15]<<8) + Reply[16];//u-dot short nZAccel = (Reply[17]<<8) + Reply[18];//w-dot //xbow calib constant double GR = 2.0;//G's double dfXAccel = nXAccel * GR * 1.5/pow(2.0,15); double dfYAccel = nYAccel * GR * 1.5/pow(2.0,15); double dfZAccel = nZAccel * GR * 1.5/pow(2.0,15); //note X and Y axes are switched CMOOSMsg XAccel(MOOS_NOTIFY, "INS_ACCEL_Y", dfXAccel); m_Notifications.push_back(XAccel); CMOOSMsg YAccel(MOOS_NOTIFY, "INS_ACCEL_X", dfYAccel); m_Notifications.push_back(YAccel); CMOOSMsg ZAccel(MOOS_NOTIFY, "INS_ACCEL_Z", dfZAccel); m_Notifications.push_back(ZAccel); //magnetic field data short nXMag = (Reply[19]<<8) + Reply[20]; short nYMag = (Reply[21]<<8) + Reply[22]; short nZMag = (Reply[23]<<8) + Reply[24]; double dfGaussX = nXMag * 1.25 * 1.5/pow(2.0,15.0); double dfGaussY = nYMag * 1.25 * 1.5/pow(2.0,15.0); double dfGaussZ = nZMag * 1.25 * 1.5/pow(2.0,15.0); CMOOSMsg GaussX(MOOS_NOTIFY, "INS_MAG_Y", dfGaussX); m_Notifications.push_back(GaussX); CMOOSMsg GaussY(MOOS_NOTIFY, "INS_MAG_X", dfGaussY); m_Notifications.push_back(GaussY); CMOOSMsg GaussZ(MOOS_NOTIFY, "INS_MAG_Z", dfGaussZ); m_Notifications.push_back(GaussZ); if(m_pPort->IsVerbose()) { //this allows us to print data in verbose mode //when teh port couldn't as it is verbose MOOSTrace("Roll = %7.3f Pitch = %7.3f Yaw = %7.3f Heading = %7.3f Temp = %3.2f\n", df_deg_TRoll, df_deg_TPitch, dfYaw*180/PI, dfHeading, m_dfTemp); } } else { MOOSTrace("read %d byte while expecting %d\n", nRead, CROSSBOW_POLLED_ANGLE_MODE_REPLY_LENGTH); } return true; }
/** Set the heading in degrees from North */ static Heading InDegrees(double deg) { return Heading((int16_t)(deg/CF)); }
int main () { textmode (ATC_TEXT_MODE); clrscr(); Position::MaxX = 30; Position::MaxY = 30; char pid; Position::MaxX = 30; Position::MaxY = 30; RadarScreen *r; Landmarks l; Traffic t; Plane *p1; Gate g (Position (0, 10), 1, D90); Gate g1 (Position (0, 0), 2, D45); Gate g2 (Position (10, 0), 3, D0); Gate g3 (Position (MAX_X, MAX_Y), 4, D225); // Gate g4 (Position (10, 0), 4, D0); Airport a1 (Position (5, 5), 1, Heading (D90)); Airport a2 (Position (10, 12), 2, Heading (D45)); Beacon b1 (Position (7,13), 1); Beacon b2 (Position (1,1), 2); FlightPath fp (Position (MIN_FIELD_X, MIN_FIELD_Y), Position (MAX_FIELD_X, MAX_FIELD_Y)); FlightPath fp1 (Position (MIN_FIELD_X, MAX_FIELD_Y), Position (MAX_FIELD_X, MIN_FIELD_Y)); FlightPath fp2 (Position (10, 1), Position (10, MAX_FIELD_Y)); int i; l.AddAirport (&a1); l.AddAirport (&a2); l.AddBeacon (&b1); l.AddBeacon (&b2); l.AddGate (&g); l.AddGate (&g1); l.AddGate (&g2); l.AddGate (&g3); // l.AddGate (&g4); l.AddFlightPath (&fp); l.AddFlightPath (&fp1); l.AddFlightPath (&fp2); r = new RadarScreen (&l); Boolean Crashed = False; r->Refresh(); pid = t.NewId(); p1 = new Plane (pid, g.NewPlaneCoords(), Prop, &g1); t.NewAirborne (p1); p1 = new Plane (t.NewId(), g1.NewPlaneCoords(), Jet, &g); t.NewAirborne (p1); p1 = new Plane (t.NewId(), g2.NewPlaneCoords(), Jet, &g); t.NewAirborne (p1); r->DisplayPlanes (&t); for (i = 0; i < 34; i++) { delay (500); if (i == 17) { t.SearchAirborne ('a'); t.FoundAirborne() -> AlterTargHeading (D270, AntiClockwise); t.SearchAirborne ('b'); t.FoundAirborne() -> MakeCircle (AntiClockwise); } r->UnDisplayPlanes (&t); if (i % 2 == 0) { t.StepJets(); } else { t.StepAll(); } r->DisplayPlanes (&t); if (!Crashed && t.Crashed ()) { cout << '\a'; Crashed = True; } } textmode (C80); _setcursortype (_NORMALCURSOR); clrscr(); return 0; }
void SpacesInteriorPartitionsGridController::addColumns(const QString &category, std::vector<QString> & fields) { // always show name and selected columns fields.insert(fields.begin(), { NAME, SELECTED }); m_baseConcepts.clear(); for (const auto &field : fields) { if (field == NAME) { addNameLineEditColumn(Heading(QString(NAME), false, false), false, false, CastNullAdapter<model::Space>(&model::Space::name), CastNullAdapter<model::Space>(&model::Space::setName) ); } else { std::function<std::vector<model::ModelObject>(const model::Space &)> allInteriorPartitionSurfaceGroups( [](const model::Space &t_space) { std::vector<model::ModelObject> allModelObjects; auto interiorPartitionSurfaceGroups = t_space.interiorPartitionSurfaceGroups(); allModelObjects.insert(allModelObjects.end(), interiorPartitionSurfaceGroups.begin(), interiorPartitionSurfaceGroups.end()); return allModelObjects; } ); std::function<std::vector<model::ModelObject>(const model::Space &)> allInteriorPartitionSurfaces( [allInteriorPartitionSurfaceGroups](const model::Space &t_space) { std::vector<model::ModelObject> allModelObjects; for (auto interiorPartitionSurfaceGroup : allInteriorPartitionSurfaceGroups(t_space)) { auto interiorPartitionSurfaces = interiorPartitionSurfaceGroup.cast<model::InteriorPartitionSurfaceGroup>().interiorPartitionSurfaces(); for (auto interiorPartitionSurface : interiorPartitionSurfaces) { allModelObjects.push_back(interiorPartitionSurface); } } return allModelObjects; } ); std::function<std::vector<boost::optional<model::ModelObject> >(const model::Space &)> allInteriorPartitionSurfaceInteriorPartitionSurfaceGroups( [allInteriorPartitionSurfaceGroups](const model::Space &t_space) { std::vector<boost::optional<model::ModelObject> > allModelObjects; for (auto interiorPartitionSurfaceGroup : allInteriorPartitionSurfaceGroups(t_space)) { auto interiorPartitionSurfaces = interiorPartitionSurfaceGroup.cast<model::InteriorPartitionSurfaceGroup>().interiorPartitionSurfaces(); for (auto interiorPartitionSurface : interiorPartitionSurfaces) { auto group = interiorPartitionSurface.interiorPartitionSurfaceGroup(); if (group) { allModelObjects.push_back(*group); } else { allModelObjects.emplace_back(); } } } return allModelObjects; } ); if (field == SELECTED) { auto checkbox = QSharedPointer<QCheckBox>(new QCheckBox()); checkbox->setToolTip("Check to select all rows"); connect(checkbox.data(), &QCheckBox::stateChanged, this, &SpacesInteriorPartitionsGridController::selectAllStateChanged); connect(checkbox.data(), &QCheckBox::stateChanged, this->gridView(), &OSGridView::gridRowSelectionChanged); addSelectColumn(Heading(QString(SELECTED), false, false, checkbox), "Check to select this row", DataSource( allInteriorPartitionSurfaces, true ) ); } else if (field == INTERIORPARTITIONGROUPNAME) { addNameLineEditColumn(Heading(QString(INTERIORPARTITIONGROUPNAME), true, false), false, false, CastNullAdapter<model::InteriorPartitionSurfaceGroup>(&model::InteriorPartitionSurfaceGroup::name), CastNullAdapter<model::InteriorPartitionSurfaceGroup>(&model::InteriorPartitionSurfaceGroup::setName), boost::optional<std::function<void(model::InteriorPartitionSurfaceGroup *)>>(), DataSource( allInteriorPartitionSurfaceInteriorPartitionSurfaceGroups, true) ); } else if (field == INTERIORPARTITIONNAME) { addNameLineEditColumn(Heading(QString(INTERIORPARTITIONNAME), true, false), false, false, CastNullAdapter<model::InteriorPartitionSurface>(&model::InteriorPartitionSurface::name), CastNullAdapter<model::InteriorPartitionSurface>(&model::InteriorPartitionSurface::setName), boost::optional<std::function<void(model::InteriorPartitionSurface *)>>(), DataSource( allInteriorPartitionSurfaces, true) ); } else if (field == CONSTRUCTIONNAME) { m_constructionColumn = 4; addDropZoneColumn(Heading(QString(CONSTRUCTIONNAME), true, false), CastNullAdapter<model::InteriorPartitionSurface>(&model::InteriorPartitionSurface::construction), CastNullAdapter<model::InteriorPartitionSurface>(&model::InteriorPartitionSurface::setConstruction), boost::optional<std::function<void(model::InteriorPartitionSurface*)> >(NullAdapter(&model::InteriorPartitionSurface::resetConstruction)), boost::optional<std::function<bool(model::InteriorPartitionSurface*)> >(NullAdapter(&model::InteriorPartitionSurface::isConstructionDefaulted)), DataSource( allInteriorPartitionSurfaces, true ) ); } else if (field == CONVERTTOINTERNALMASS) { addCheckBoxColumn(Heading(QString(CONVERTTOINTERNALMASS), true, false), std::string("Check to enable convert to InternalMass."), NullAdapter(&model::InteriorPartitionSurface::converttoInternalMass), NullAdapter(&model::InteriorPartitionSurface::setConverttoInternalMass), DataSource( allInteriorPartitionSurfaces, true ) ); } else if (field == SURFACEAREA) { std::function<bool(model::InteriorPartitionSurface *, double)> setter( [](model::InteriorPartitionSurface *t_interiorPartitionSurface, double t_arg) { return t_interiorPartitionSurface->setSurfaceArea(t_arg); } ); addValueEditColumn(Heading(QString(SURFACEAREA)), CastNullAdapter<model::InteriorPartitionSurface>(&model::InteriorPartitionSurface::surfaceArea), setter//, //boost::optional<std::function<void(model::ModelObject *)>>(), //boost::optional<std::function<bool(model::ModelObject *)>>()//, //DataSource( //allInteriorPartitionSurfaces, //true //) ); //boost::optional<double> surfaceArea() const; // TODO this optional is causing troubles //bool setSurfaceArea(boost::optional<double> surfaceArea); //bool setSurfaceArea(double surfaceArea); //void resetSurfaceArea(); } else if (field == DAYLIGHTINGSHELFNAME) { //boost::optional<DaylightingDeviceShelf> daylightingDeviceShelf() const; } else { // unhandled OS_ASSERT(false); } } } }
bool DoCalculations(NMEA_INFO *Basic, DERIVED_INFO *Calculated) { // first thing: assign navaltitude! EnergyHeightNavAltitude(Basic, Calculated); // second thing: if available, get external wind precalculated! if ( (Basic->ExternalWindAvailable==TRUE) && (AutoWindMode==D_AUTOWIND_EXTERNAL)) { if (Basic->ExternalWindSpeed>0 && Basic->ExternalWindSpeed<35) { Calculated->WindSpeed = Basic->ExternalWindSpeed; Calculated->WindBearing = Basic->ExternalWindDirection; } } Heading(Basic, Calculated); DistanceToNext(Basic, Calculated); DistanceToHome(Basic, Calculated); DetectFreeFlying(Basic,Calculated); // check ongoing powerless flight DoLogging(Basic, Calculated); TerrainHeight(Basic, Calculated); AltitudeRequired(Basic, Calculated, MACCREADY); DoAlternates(Basic,Calculated,TASKINDEX); if (IsMultiMapShared()) { DoAlternates(Basic,Calculated,RESWP_LASTTHERMAL); DoAlternates(Basic,Calculated,RESWP_TEAMMATE); DoAlternates(Basic,Calculated,RESWP_FLARMTARGET); DoAlternates(Basic,Calculated,HomeWaypoint); if (DoOptimizeRoute() || ACTIVE_WP_IS_AAT_AREA) { DoAlternates(Basic, Calculated, RESWP_OPTIMIZED); } for (int i=RESWP_FIRST_MARKER; i<=RESWP_LAST_MARKER; i++) { if (WayPointList[i].Latitude==RESWP_INVALIDNUMBER) continue; DoAlternates(Basic,Calculated,i); } } else { // The following is needed only for the next-WP glide terrain line, // not for the main/primary glide terrain line. if ((FinalGlideTerrain > 2) && (DoOptimizeRoute() || ACTIVE_WP_IS_AAT_AREA)) DoAlternates(Basic, Calculated, RESWP_OPTIMIZED); } if (!TargetDialogOpen) { // don't calculate these if optimise function being invoked or // target is being adjusted TaskStatistics(Basic, Calculated, MACCREADY); AATStats(Basic, Calculated); TaskSpeed(Basic, Calculated, MACCREADY); } if (!FlightTimes(Basic, Calculated)) { // time hasn't advanced, so don't do calculations requiring an advance // or movement return false; } Turning(Basic, Calculated); LD(Basic,Calculated); CruiseLD(Basic,Calculated); // We calculate flaps settings only if the polar is extended. // We do assume that GA planes will NOT use extended polars if (GlidePolar::FlapsPosCount >0) Flaps(Basic,Calculated); Calculated->AverageLD=CalculateLDRotary(&rotaryLD,Basic,Calculated); Average30s(Basic,Calculated); AverageThermal(Basic,Calculated); AverageClimbRate(Basic,Calculated); ThermalGain(Basic,Calculated); LastThermalStats(Basic, Calculated); // ThermalBand(Basic, Calculated); moved to % circling function MaxHeightGain(Basic,Calculated); PredictNextPosition(Basic, Calculated); if (Orbiter) CalculateOrbiter(Basic,Calculated); CalculateOwnTeamCode(Basic, Calculated); CalculateTeammateBearingRange(Basic, Calculated); BallastDump(); // reminder: Paragliders have AAT always on CalculateOptimizedTargetPos(Basic,Calculated); if (ValidTaskPoint(ActiveTaskPoint)) { // only if running a real task if (ValidTaskPoint(1)) InSector(Basic, Calculated); DoAutoMacCready(Basic, Calculated); #ifdef DEBUGTASKSPEED DebugTaskCalculations(Basic, Calculated); #endif } else { // 101002 DoAutoMacCready(Basic, Calculated); // will set only EqMC } DoAlternates(Basic, Calculated,Alternate1); DoAlternates(Basic, Calculated,Alternate2); DoAlternates(Basic, Calculated,BestAlternate); // Calculate nearest waypoints when needed if ( !MapWindow::mode.AnyPan() && DrawBottom && (MapSpaceMode>MSM_MAP) ) { switch(MapSpaceMode) { case MSM_LANDABLE: case MSM_AIRPORTS: case MSM_NEARTPS: // 101222 DoNearest(Basic,Calculated); break; case MSM_COMMON: DoCommon(Basic,Calculated); break; case MSM_RECENT: DoRecent(Basic,Calculated); break; case MSM_VISUALGLIDE: // Only if visualglide is really painted: topview is not fullscreen. if (Current_Multimap_SizeY<SIZE4) { DoNearest(Basic,Calculated); } break; } } CalculateHeadWind(Basic,Calculated); ConditionMonitorsUpdate(Basic, Calculated); return true; }