string Div::ToString() const { string result; if (leftOperand->GetPriority() <= GetPriority()) { result += "(" + leftOperand->ToString() + ")"; } else { result += leftOperand->ToString(); } result += " " + name + " "; if (rightOperand->GetPriority() <= GetPriority()) { result += "(" + rightOperand->ToString() + ")"; } else { result += rightOperand->ToString(); } return result; }
static DLIST * FindInsertPoint( OBJPTR original ) /***********************************************/ /* order the clipboard list so that higher level objects are added before * lower level ones */ { int priority; int currpr; DLIST * lst; DLIST * prev; DLIST_ELT elt; prev = NULL; GetPriority( original, &priority ); for( lst = ClipBoard.objs; lst != NULL; lst = DListNext( lst ) ) { elt = DListElement( lst ); GetPriority( elt.copy, &currpr ); if( currpr < priority ) { break; } prev = lst; } return( prev ); }
/************************************************************************************************ * CRMObjective::CRMObjective * Constructs a random mission objective and fills in the default properties * * inputs: * none * * return: * none * ************************************************************************************************/ CRMObjective::CRMObjective ( CGPGroup* group ) { SetPriority(atoi(group->FindPairValue("priority", "0"))); SetMessage( group->FindPairValue("message",va("Objective %i Completed", GetPriority()) ) ); SetDescription(group->FindPairValue("description",va("Objective %i", GetPriority()) ) ); SetInfo(group->FindPairValue("info",va("Info %i", GetPriority()) ) ); SetTrigger(group->FindPairValue("trigger","")); SetName(group->GetName()); /* const char * soundPath = group->FindPairValue("completed_sound", "" ); if (soundPath) mCompleteSoundID = G_SoundIndex(soundPath); */ mCompleted = false; mOrderIndex = -1; // If no priority was specified for this objective then its active by default. if ( GetPriority ( ) ) { mActive = false; } else { mActive = true; } }
//-------------------------------------------------------------------------- void VeRenderNode::LinkToParent() { if((!IsAttach()) && m_pkParent) { VeRefList<VeRenderNode*>& kRenderList = m_pkParent->m_kRenderChildren; switch(m_u32Priority) { case 0: kRenderList.AttachFront(*this); break; case VE_INFINITE: kRenderList.AttachBack(*this); break; default: { VeRefList<VeRenderNode*>::iterator it = kRenderList.GetHeadNode(); while(!kRenderList.IsEnd(it)) { if(GetPriority() < it->m_tContent->GetPriority()) { kRenderList.AttachBefore(*it, *this); } VeRefList<VeRenderNode*>::Next(it); } if(!IsAttach()) { kRenderList.AttachBack(*this); } } break; } m_pkParent->LinkToParent(); } }
wxThread::ExitCode MyThread::Entry() { wxLogMessage("Thread started (priority = %u).", GetPriority()); for ( m_count = 0; m_count < 10; m_count++ ) { // check if the application is shutting down: in this case all threads // should stop a.s.a.p. { wxCriticalSectionLocker locker(wxGetApp().m_critsect); if ( wxGetApp().m_shuttingDown ) return NULL; } // check if just this thread was asked to exit if ( TestDestroy() ) break; wxLogMessage("Thread progress: %u", m_count); // wxSleep() can't be called from non-GUI thread! wxThread::Sleep(1000); } wxLogMessage("Thread finished."); return NULL; }
/** * Function IsSame * test is 2 zones are equivalent: * 2 zones are equivalent if they have same parameters and same outlines * info relative to filling is not take in account * @param aZoneToCompare = zone to compare with "this" */ bool ZONE_CONTAINER::IsSame( const ZONE_CONTAINER& aZoneToCompare ) { // compare basic parameters: if( GetLayer() != aZoneToCompare.GetLayer() ) return false; if( GetNetCode() != aZoneToCompare.GetNetCode() ) return false; if( GetPriority() != aZoneToCompare.GetPriority() ) return false; // Compare zone specific parameters if( GetIsKeepout() != aZoneToCompare.GetIsKeepout() ) return false; if( GetIsKeepout() ) { if( GetDoNotAllowCopperPour() != aZoneToCompare.GetDoNotAllowCopperPour() ) return false; if( GetDoNotAllowVias() != aZoneToCompare.GetDoNotAllowVias() ) return false; if( GetDoNotAllowTracks() != aZoneToCompare.GetDoNotAllowTracks() ) return false; } if( m_ArcToSegmentsCount != aZoneToCompare.GetArcSegmentCount() ) return false; if( m_ZoneClearance != aZoneToCompare.m_ZoneClearance ) return false; if( m_ZoneMinThickness != aZoneToCompare.GetMinThickness() ) return false; if( m_FillMode != aZoneToCompare.GetFillMode() ) return false; if( m_PadConnection != aZoneToCompare.m_PadConnection ) return false; if( m_ThermalReliefGap != aZoneToCompare.m_ThermalReliefGap ) return false; if( m_ThermalReliefCopperBridge != aZoneToCompare.m_ThermalReliefCopperBridge ) return false; // Compare outlines wxASSERT( m_Poly ); // m_Poly == NULL Should never happen wxASSERT( aZoneToCompare.Outline() ); if( Outline()->m_CornersList.GetList() != aZoneToCompare.Outline()->m_CornersList.GetList() ) // Compare vector return false; return true; }
// This method gets the partition details such as the attributes, the // guids of the partitions, etc. Input is the partition number or the // unique id of the partition. Output is populated in the respective // fields of params. int CgptGetPartitionDetails(CgptAddParams *params) { struct drive drive; int result = CGPT_FAILED; int index; if (params == NULL) return CGPT_FAILED; if (CGPT_OK != DriveOpen(params->drive_name, &drive, O_RDWR)) return CGPT_FAILED; if (CgptCheckAddValidity(&drive)) { goto bad; } int max_part = GetNumberOfEntries(&drive); if (params->partition > 0) { if (params->partition >= max_part) { Error("invalid partition number: %d\n", params->partition); goto bad; } } else { if (!params->set_unique) { Error("either partition or unique_id must be specified\n"); goto bad; } for (index = 0; index < max_part; index++) { GptEntry *entry = GetEntry(&drive.gpt, PRIMARY, index); if (GuidEqual(&entry->unique, ¶ms->unique_guid)) { params->partition = index + 1; break; } } if (index >= max_part) { Error("no partitions with the given unique id available\n"); goto bad; } } index = params->partition - 1; { // GPT-specific code GptEntry *entry = GetEntry(&drive.gpt, PRIMARY, index); params->begin = entry->starting_lba; params->size = entry->ending_lba - entry->starting_lba + 1; memcpy(¶ms->type_guid, &entry->type, sizeof(Guid)); memcpy(¶ms->unique_guid, &entry->unique, sizeof(Guid)); params->raw_value = entry->attrs.fields.gpt_att; } params->successful = GetSuccessful(&drive, PRIMARY, index); params->tries = GetTries(&drive, PRIMARY, index); params->priority = GetPriority(&drive, PRIMARY, index); result = CGPT_OK; bad: DriveClose(&drive, 0); return result; }
int CWorkerThread::BoostPriority() { int iInitialPriority = GetPriority(); const int iNewPriority = ::GetThreadPriority(GetCurrentThread()); if (iNewPriority > iInitialPriority) SetPriority(iNewPriority); return iInitialPriority; }
std::string TextHandle::GetOverlayDebugInfo() { std::ostringstream out; out << "Text Priority(" << std::hex << GetPriority() << ") " << std::dec << GetOverlayID().m_featureId.m_index << "-" << GetOverlayID().m_index << " " << strings::ToUtf8(m_text); return out.str(); }
// Sorts the brigade's elements by relative importance void BrigadeClass::ReorganizeUnit (void) { Unit e,ne; int i,j; for (i=0; i<elements; i++) { e = GetUnitElement(i); for (j=i; j<elements; j++) { ne = GetUnitElement(j); if (ne && e && GetPriority(ne) > GetPriority(e)) { element[i] = ne->Id(); element[j] = e->Id(); e = ne; } } } }
bool UPawnAction::PushChildAction(UPawnAction& Action) { bool bResult = false; if (OwnerComponent != NULL) { UE_CVLOG( ChildAction != NULL , GetPawn(), LogPawnAction, Log, TEXT("%s> Pushing child action %s while already having ChildAction set to %s") , *GetName(), *Action.GetName(), *ChildAction->GetName()); // copy runtime data // note that priority and instigator will get assigned as part of PushAction. bResult = OwnerComponent->PushAction(Action, GetPriority(), Instigator); // adding a check to make sure important data has been set ensure(Action.GetPriority() == GetPriority() && Action.GetInstigator() == GetInstigator()); } return bResult; }
/********************************************************************** * Set the task priority to the resource priority. * See the ceiling protocol of the OSEK/VDX standart. * * @param ID IN ID of the resource to be accessed * @return Status E_OS_ACCESS if the resource does not exist * Elsewise the function never returns **********************************************************************/ StatusType GetResource(ResourceType ID) { if (ID >= RESOURCENUMBER) return (E_OS_ID); if (Resource_list[ID].lock == 1) return E_OS_ACCESS; GetPriority(&Resource_list[ID].Taskprio, id_tsk_run); SetPriority(Resource_list[ID].priority, id_tsk_run); Resource_list[ID].lock = 1; Organize(); return(E_OK); }
void CAnimActionBlendFromRagdollSleep::Enter() { TBase::Enter(); SGameObjectEvent event( eGFE_EnableBlendRagdoll, eGOEF_ToExtensions ); event.ptr = &m_hitInfo; m_actor.GetGameObject()->SendEvent( event ); #ifdef USE_BLEND_FROM_RAGDOLL m_rootScope->GetActionController().Queue( new CAnimActionBlendFromRagdoll(GetPriority(), m_actor, m_fragmentID, m_fragTagsTarget) ); #endif //USE_BLEND_FROM_RAGDOLL }
/* * Write data to this port. */ bool E131OutputPort::WriteDMX(const DmxBuffer &buffer, uint8_t priority) { Universe *universe = GetUniverse(); if (!universe) return false; if (GetPriorityMode() == PRIORITY_MODE_OVERRIDE) priority = GetPriority(); return m_node->SendDMX(universe->UniverseId(), buffer, priority, m_preview_on); }
CDataLoader* CSRA_DataLoaderCF::CreateAndRegister( CObjectManager& om, const TPluginManagerParamTree* params) const { if ( !ValidParams(params) ) { // Use constructor without arguments return CSRADataLoader::RegisterInObjectManager(om).GetLoader(); } // IsDefault and Priority arguments may be specified return CSRADataLoader::RegisterInObjectManager( om, GetIsDefault(params), GetPriority(params)).GetLoader(); }
void CServerDefinitions::LoadDFNCategory( DEFINITIONCATEGORIES toLoad ) { CleanPriorityMap(); defaultPriority = 0; UI08 wasPriod = 2; BuildPriorityMap( toLoad, wasPriod ); cDirectoryListing fileList( toLoad, defExt ); fileList.Flatten( true ); STRINGLIST *shortListing = fileList.FlattenedShortList(); STRINGLIST *longListing = fileList.FlattenedList(); std::vector< PrioScan > mSort; for( size_t i = 0; i < shortListing->size(); ++i ) { mSort.push_back( PrioScan( (*longListing)[i].c_str(), GetPriority( (*shortListing)[i].c_str() ) ) ); } if( !mSort.empty() ) { std::sort( mSort.begin(), mSort.end() ); Console.Print( "Section %20s : %6i", dirnames[toLoad].c_str(), 0 ); size_t iTotal = 0; Console.TurnYellow(); std::vector< PrioScan >::const_iterator mIter; for( mIter = mSort.begin(); mIter != mSort.end(); ++mIter ) { Console.Print( "\b\b\b\b\b\b" ); ScriptListings[toLoad].push_back( new Script( (*mIter).filename, toLoad, false ) ); iTotal += ScriptListings[toLoad].back()->NumEntries(); Console.Print( "%6i", iTotal ); } Console.Print( "\b\b\b\b\b\b%6i", CountOfEntries( toLoad ) ); Console.TurnNormal(); Console.Print( " entries" ); switch( wasPriod ) { case 0: Console.PrintSpecial( CGREEN, "prioritized" ); break; // prioritized case 1: Console.PrintSpecial( CGREEN, "done" ); break; // file exist, no section default: case 2: Console.PrintSpecial( CBLUE, "done" ); break; // no file }; } }
void KnxTelegram::InfoVerbose(String& str) const { byte payloadLength = GetPayloadLength(); str+= "Repeat="; str+= IsRepeated() ? "YES" : "NO"; str+="\nPrio="; switch(GetPriority()) { case KNX_PRIORITY_SYSTEM_VALUE : str+="SYSTEM"; break; case KNX_PRIORITY_ALARM_VALUE : str+="ALARM"; break; case KNX_PRIORITY_HIGH_VALUE : str+="HIGH"; break; case KNX_PRIORITY_NORMAL_VALUE : str+="NORMAL"; break; default : str+="ERR_VAL!"; break; } str+="\nSrcAddr=" + String(GetSourceAddress(),HEX); str+="\nTargetAddr=" + String(GetTargetAddress(),HEX); str+="\nGroupAddr="; if (IsMulticast()) str+= "YES"; else str+="NO"; str+="\nRout.Counter=" + String(GetRoutingCounter(),DEC); str+="\nPayloadLgth=" + String(payloadLength,DEC); str+="\nTelegramLength=" + String(GetTelegramLength(),DEC); str+="\nCommand="; switch(GetCommand()) { case KNX_COMMAND_VALUE_READ : str+="VAL_READ"; break; case KNX_COMMAND_VALUE_RESPONSE : str+="VAL_RESP"; break; case KNX_COMMAND_VALUE_WRITE : str+="VAL_WRITE"; break; case KNX_COMMAND_MEMORY_WRITE : str+="MEM_WRITE"; break; default : str+="ERR_VAL!"; break; } str+="\nPayload=" + String(GetFirstPayloadByte(),HEX)+' '; for (byte i = 0; i < payloadLength-1; i++) str+=String(_payloadChecksum[i], HEX)+' '; str+="\nValidity="; switch(GetValidity()) { case KNX_TELEGRAM_VALID : str+="VALID"; break; case KNX_TELEGRAM_INVALID_CONTROL_FIELD : str+="INVALID_CTRL_FIELD"; break; case KNX_TELEGRAM_UNSUPPORTED_FRAME_FORMAT : str+="UNSUPPORTED_FRAME_FORMAT"; break; case KNX_TELEGRAM_INCORRECT_PAYLOAD_LENGTH : str+="INCORRECT_PAYLOAD_LGTH"; break; case KNX_TELEGRAM_INVALID_COMMAND_FIELD : str+="INVALID_CMD_FIELD"; break; case KNX_TELEGRAM_UNKNOWN_COMMAND : str+="UNKNOWN_CMD"; break; case KNX_TELEGRAM_INCORRECT_CHECKSUM : str+="INCORRECT_CHKSUM"; break; default : str+="ERR_VAL!"; break; } str+='\n'; }
void *OPJParseThread::Entry() { printf("Entering\n\n"); wxString text; srand(GetId()); int m_countnum = rand() % 9; text.Printf(wxT("Parse thread 0x%lx started (priority = %u, time = %d)."), GetId(), GetPriority(), m_countnum); WriteText(text); LoadFile(m_tree->m_fname); text.Printf(wxT("Parse thread 0x%lx finished."), GetId()); WriteText(text); //wxLogMessage(wxT("Entering\n")); //test wxLog thread safeness //wxBusyCursor wait; //wxBusyInfo wait(wxT("Decoding image ...")); /*for ( m_count = 0; m_count < m_countnum; m_count++ ) { // check if we were asked to exit if ( TestDestroy() ) break; text.Printf(wxT("[%u] Parse thread 0x%lx here."), m_count, GetId()); WriteText(text); // wxSleep() can't be called from non-GUI thread! wxThread::Sleep(10); }*/ // wxLogMessage(text); -- test wxLog thread safeness printf("Exiting\n\n"); return NULL; }
MojErr ResourceContainer::ToJson(MojObject& rep) const { MojErr err = rep.putString(_T("name"), m_name.c_str()); MojErrCheck(err); err = rep.putString(_T("priority"), ActivityPriorityNames[GetPriority()]); MojErrCheck(err); err = rep.putBool(_T("focused"), IsFocused()); MojErrCheck(err); MojObject entities(MojObject::TypeArray); std::for_each(m_entities.begin(), m_entities.end(), boost::bind(&BusEntity::PushJson, _1, boost::ref(entities), false)); err = rep.put(_T("entities"), entities); MojErrCheck(err); return MojErrNone; }
static int do_search(CgptNextParams *params) { struct drive drive; uint32_t max_part; int gpt_retval; int priority, tries, successful; int i; if (CGPT_OK != DriveOpen(params->drive_name, &drive, 0, O_RDONLY)) return CGPT_FAILED; if (GPT_SUCCESS != (gpt_retval = GptSanityCheck(&drive.gpt))) { Error("GptSanityCheck() returned %d: %s\n", gpt_retval, GptError(gpt_retval)); return CGPT_FAILED; } max_part = GetNumberOfEntries(&drive); for (i = 0; i < max_part; i++) { if (!IsRoot(&drive, PRIMARY, i)) continue; priority = GetPriority(&drive, PRIMARY, i); tries = GetTries(&drive, PRIMARY, i); successful = GetSuccessful(&drive, PRIMARY, i); if (next_index == -1 || ((priority > next_priority) && (successful || tries))) { strncpy(next_file_name, params->drive_name, BUFSIZE); if (successful || tries) { next_priority = priority; } else { next_priority = -1; } next_index = i; } } return DriveClose(&drive, 0); }
DBOS_RESULT_t dBOS_SYNC::InsertTaskIntoObjectWaitList(dBOS_LISTNODE<dBOS_TASK> * const pTaskWaitLink){ DBOS_RESULT_t Result; ASSERT_FROM_OSCS(pTaskWaitLink != NULLPTR) ASSERT_FROM_OSCS(pTaskWaitLink->GetItem() != NULLPTR) m_pWaitList->AddTaskToQueue(pTaskWaitLink); dBOS_LISTNODE<dBOS_TASK> const * const pHead = m_pWaitList->GetNextTaskFromQueue(); ASSERT_FROM_OSCS(pHead != NULLPTR) DBOS_TASK_CONST_P_t const pTask = pHead->GetItem(); ASSERT_FROM_OSCS(pTask != NULLPTR) m_Priority = pTask->GetPriority(); // Sync Object inherits priority of highest priority task // which is the first task in the list. Result = DBOS_DONE; return Result; }
void QualityOfServiceData::Init() { ReadParameters(); if (!IsStandalone()) { Dob::Typesystem::TypeIdVector typeIds = Safir::Dob::Typesystem::Operations::GetAllTypeIds(); for (Dob::Typesystem::TypeIdVector::iterator it = typeIds.begin(); it != typeIds.end(); ++it) { if (Dob::Typesystem::Operations::IsOfType(*it,Safir::Dob::Entity::ClassTypeId) || Dob::Typesystem::Operations::IsOfType(*it,Safir::Dob::Service::ClassTypeId) || Dob::Typesystem::Operations::IsOfType(*it,Safir::Dob::Message::ClassTypeId) || Dob::Typesystem::Operations::IsOfType(*it,Safir::Dob::Response::ClassTypeId)) { m_QoSTable.insert(QoSTable::value_type(*it,QoSData(GetDistributionChannel(*it), GetPriority(*it)))); } } } }
FString UPawnAction::GetPriorityName() const { static const UEnum* Enum = FindObject<UEnum>(ANY_PACKAGE, TEXT("EAIRequestPriority")); check(Enum); return Enum->GetEnumName(GetPriority()); }
// -------------------------------------------------------------------------- // // Sound property functions // -------------------------------------------------------------------------- // void VFmodSoundObject::Play(float fStartTime, bool bAlsoInEditor) { if (m_spResource == NULL || IsPlaying()) return; if (!bAlsoInEditor && !Vision::Editor.IsAnimatingOrPlaying()) return; m_fStartTime = fStartTime; VFmodManager &manager = VFmodManager::GlobalManager(); if (manager.IsInitialized()) { const hkvVec3 &vPos = GetPosition(); // stop old playing if (m_pChannel) m_pChannel->stop(); VFmodSoundResource* pResource = (VFmodSoundResource*)GetResource(); if (pResource->m_pSound == NULL) // sound resource not loaded successfully return; FMOD_WARNINGCHECK(manager.m_pSystem->playSound(FMOD_CHANNEL_FREE, pResource->m_pSound, true, &m_pChannel)); if (!m_pChannel) return; FMOD_WARNINGCHECK(m_pChannel->getFrequency(&m_fInitialFreq)); // if this a music sound object assign it to the music channel group if (IsMusic()) m_pChannel->setChannelGroup(manager.m_pMusicGroup); // set everything m_pChannel->setUserData(this); // ...so that we can get from channel to VSoundObject m_pChannel->setCallback(ChannelCallback); m_pChannel->setMode(IsLooped() ? FMOD_LOOP_NORMAL : FMOD_LOOP_OFF); m_pChannel->setPriority(GetPriority()); m_pChannel->set3DMinMaxDistance(Get3DFadeMinDistance(), Get3DFadeMaxDistance()); m_pChannel->set3DAttributes((FMOD_VECTOR *)&vPos, NULL); // no speed (yet) m_pChannel->setVolume(GetVolume()); m_pChannel->setPan(GetPan()); SetPitch(GetPitch()); SetConeAngles(GetConeAngleInside(), GetConeAngleOutside()); // Initially the sound is left paused, then within the first RunTick it is unpaused. This is required since // the 3D listener attributes has to be set prior to playing a sound. Otherwise Fmod would perform // occlusion-raycasts without having initialized listener-attributes, which potentially results in a // wrong occlusion-behavior. m_bUnpause = true; m_bIsPlaying = true; m_bPlayedOnce = true; unsigned int ims = (int)(fStartTime*1000.f); // milliseconds m_pChannel->setPosition(ims,FMOD_TIMEUNIT_MS); m_pChannel->setMute(IsMuted()); } Helper_SetFlag(VFMOD_FLAG_PAUSED, !IsPlaying()); }
//-------------------------------------------------------------------------------------- // Class: YARPSoundDeviceDriver // Method: Body() // Description: Here, the body of the thread should be implemented //-------------------------------------------------------------------------------------- void YARPSoundDeviceDriver::Body (void) { SoundResources& d = RES(system_resources); MSG msg; const int prio = ACE_Sched_Params::next_priority (ACE_SCHED_OTHER, GetPriority(), ACE_SCOPE_THREAD); SetPriority (prio); //---------------------------------------------------------------------- // Wait for a message sent by the audio driver //---------------------------------------------------------------------- while (GetMessage(&msg, 0, 0, 0) == 1 && !IsTerminated()) { switch (msg.message) { case MM_WIM_DATA: //Buffer filled /********************************************************************************* * the msg.lParam contains a pointer to the WAVEHDR structure for the filled buffer. * *********************************************************************************/ if (((WAVEHDR *)msg.lParam)->dwBytesRecorded) { //---------------------------------------------------------------------- // Here write in the local buffer using the syncronization mutexes //---------------------------------------------------------------------- if (d._bmutex.PollingWait () == 1) { // buffer acquired. Reading from the buffer if (d.m_InRecord) memcpy (d._rawBuffer, ((WAVEHDR *)msg.lParam)->lpData, ((WAVEHDR *)msg.lParam)->dwBytesRecorded); // Note: is this right? // The buffer could not be full... if (d._canpost) { d._canpost = false; d._new_frame.Post(); } d._bmutex.Post (); } else { //---------------------------------------------------------------------- // can't acquire, it means the buffer is still in use. // silently ignores this condition. //---------------------------------------------------------------------- ACE_DEBUG ((LM_DEBUG, "lost a frame, acq thread\n")); } } //---------------------------------------------------------------------- // Requeue the used buffer //---------------------------------------------------------------------- waveInAddBuffer(d.m_WaveInHandle, (WAVEHDR *)msg.lParam, sizeof(WAVEHDR)); break; /* Our main thread is opening the WAVE device */ case MM_WIM_OPEN: ACE_DEBUG ((LM_DEBUG, "yarpsounddriver: sound device opened\n")); break; /* Our main thread is closing the WAVE device */ case MM_WIM_CLOSE: break; default: //ACE_DEBUG ((LM_DEBUG, "yarpsounddriver: received an unknown message\n")); break; } } ACE_DEBUG ((LM_DEBUG, "acquisition thread returning...\n")); }
void ZONE_CONTAINER::GetMsgPanelInfo( std::vector< MSG_PANEL_ITEM >& aList ) { wxString msg; msg = _( "Zone Outline" ); // Display Cutout instead of Outline for holes inside a zone // i.e. when num contour !=0 int ncont = m_Poly->GetContour( m_CornerSelection ); if( ncont ) msg << wxT( " " ) << _( "(Cutout)" ); aList.push_back( MSG_PANEL_ITEM( _( "Type" ), msg, DARKCYAN ) ); if( GetIsKeepout() ) { msg.Empty(); if( GetDoNotAllowVias() ) AccumulateDescription( msg, _("No via") ); if( GetDoNotAllowTracks() ) AccumulateDescription( msg, _("No track") ); if( GetDoNotAllowCopperPour() ) AccumulateDescription( msg, _("No copper pour") ); aList.push_back( MSG_PANEL_ITEM( _( "Keepout" ), msg, RED ) ); } else if( IsOnCopperLayer() ) { if( GetNetCode() >= 0 ) { NETINFO_ITEM* equipot = GetNet(); if( equipot ) msg = equipot->GetNetname(); else msg = wxT( "<noname>" ); } else // a netcode < 0 is an error { msg = wxT( " [" ); msg << GetNetname() + wxT( "]" ); msg << wxT( " <" ) << _( "Not Found" ) << wxT( ">" ); } aList.push_back( MSG_PANEL_ITEM( _( "NetName" ), msg, RED ) ); #if 1 // Display net code : (useful in test or debug) msg.Printf( wxT( "%d" ), GetNetCode() ); aList.push_back( MSG_PANEL_ITEM( _( "NetCode" ), msg, RED ) ); #endif // Display priority level msg.Printf( wxT( "%d" ), GetPriority() ); aList.push_back( MSG_PANEL_ITEM( _( "Priority" ), msg, BLUE ) ); } else { aList.push_back( MSG_PANEL_ITEM( _( "Non Copper Zone" ), wxEmptyString, RED ) ); } aList.push_back( MSG_PANEL_ITEM( _( "Layer" ), GetLayerName(), BROWN ) ); msg.Printf( wxT( "%d" ), (int) m_Poly->m_CornersList.GetCornersCount() ); aList.push_back( MSG_PANEL_ITEM( _( "Corners" ), msg, BLUE ) ); if( m_FillMode ) msg = _( "Segments" ); else msg = _( "Polygons" ); aList.push_back( MSG_PANEL_ITEM( _( "Fill mode" ), msg, BROWN ) ); // Useful for statistics : msg.Printf( wxT( "%d" ), (int) m_Poly->m_HatchLines.size() ); aList.push_back( MSG_PANEL_ITEM( _( "Hatch lines" ), msg, BLUE ) ); if( m_FilledPolysList.GetCornersCount() ) { msg.Printf( wxT( "%d" ), (int) m_FilledPolysList.GetCornersCount() ); aList.push_back( MSG_PANEL_ITEM( _( "Corners in DrawList" ), msg, BLUE ) ); } }
void ZONE_CONTAINER::buildFeatureHoleList( BOARD* aPcb, SHAPE_POLY_SET& aFeatures ) { int segsPerCircle; double correctionFactor; // Set the number of segments in arc approximations if( m_ArcToSegmentsCount == ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF ) segsPerCircle = ARC_APPROX_SEGMENTS_COUNT_HIGHT_DEF; else segsPerCircle = ARC_APPROX_SEGMENTS_COUNT_LOW_DEF; /* calculates the coeff to compensate radius reduction of holes clearance * due to the segment approx. * For a circle the min radius is radius * cos( 2PI / s_CircleToSegmentsCount / 2) * s_Correction is 1 /cos( PI/s_CircleToSegmentsCount ) */ correctionFactor = 1.0 / cos( M_PI / (double) segsPerCircle ); aFeatures.RemoveAllContours(); int outline_half_thickness = m_ZoneMinThickness / 2; int zone_clearance = std::max( m_ZoneClearance, GetClearance() ); zone_clearance += outline_half_thickness; /* store holes (i.e. tracks and pads areas as polygons outlines) * in a polygon list */ /* items ouside the zone bounding box are skipped * the bounding box is the zone bounding box + the biggest clearance found in Netclass list */ EDA_RECT item_boundingbox; EDA_RECT zone_boundingbox = GetBoundingBox(); int biggest_clearance = aPcb->GetDesignSettings().GetBiggestClearanceValue(); biggest_clearance = std::max( biggest_clearance, zone_clearance ); zone_boundingbox.Inflate( biggest_clearance ); /* * First : Add pads. Note: pads having the same net as zone are left in zone. * Thermal shapes will be created later if necessary */ int item_clearance; /* Use a dummy pad to calculate hole clerance when a pad is not on all copper layers * and this pad has a hole * This dummy pad has the size and shape of the hole * Therefore, this dummy pad is a circle or an oval. * A pad must have a parent because some functions expect a non null parent * to find the parent board, and some other data */ MODULE dummymodule( aPcb ); // Creates a dummy parent D_PAD dummypad( &dummymodule ); for( MODULE* module = aPcb->m_Modules; module; module = module->Next() ) { D_PAD* nextpad; for( D_PAD* pad = module->Pads(); pad != NULL; pad = nextpad ) { nextpad = pad->Next(); // pad pointer can be modified by next code, so // calculate the next pad here if( !pad->IsOnLayer( GetLayer() ) ) { /* Test for pads that are on top or bottom only and have a hole. * There are curious pads but they can be used for some components that are * inside the board (in fact inside the hole. Some photo diodes and Leds are * like this) */ if( pad->GetDrillSize().x == 0 && pad->GetDrillSize().y == 0 ) continue; // Use a dummy pad to calculate a hole shape that have the same dimension as // the pad hole dummypad.SetSize( pad->GetDrillSize() ); dummypad.SetOrientation( pad->GetOrientation() ); dummypad.SetShape( pad->GetDrillShape() == PAD_DRILL_SHAPE_OBLONG ? PAD_SHAPE_OVAL : PAD_SHAPE_CIRCLE ); dummypad.SetPosition( pad->GetPosition() ); pad = &dummypad; } // Note: netcode <=0 means not connected item if( ( pad->GetNetCode() != GetNetCode() ) || ( pad->GetNetCode() <= 0 ) ) { item_clearance = pad->GetClearance() + outline_half_thickness; item_boundingbox = pad->GetBoundingBox(); item_boundingbox.Inflate( item_clearance ); if( item_boundingbox.Intersects( zone_boundingbox ) ) { int clearance = std::max( zone_clearance, item_clearance ); pad->TransformShapeWithClearanceToPolygon( aFeatures, clearance, segsPerCircle, correctionFactor ); } continue; } // Pads are removed from zone if the setup is PAD_ZONE_CONN_NONE if( GetPadConnection( pad ) == PAD_ZONE_CONN_NONE ) { int gap = zone_clearance; int thermalGap = GetThermalReliefGap( pad ); gap = std::max( gap, thermalGap ); item_boundingbox = pad->GetBoundingBox(); item_boundingbox.Inflate( gap ); if( item_boundingbox.Intersects( zone_boundingbox ) ) { pad->TransformShapeWithClearanceToPolygon( aFeatures, gap, segsPerCircle, correctionFactor ); } } } } /* Add holes (i.e. tracks and vias areas as polygons outlines) * in cornerBufferPolysToSubstract */ for( TRACK* track = aPcb->m_Track; track; track = track->Next() ) { if( !track->IsOnLayer( GetLayer() ) ) continue; if( track->GetNetCode() == GetNetCode() && (GetNetCode() != 0) ) continue; item_clearance = track->GetClearance() + outline_half_thickness; item_boundingbox = track->GetBoundingBox(); if( item_boundingbox.Intersects( zone_boundingbox ) ) { int clearance = std::max( zone_clearance, item_clearance ); track->TransformShapeWithClearanceToPolygon( aFeatures, clearance, segsPerCircle, correctionFactor ); } } /* Add module edge items that are on copper layers * Pcbnew allows these items to be on copper layers in microwave applictions * This is a bad thing, but must be handled here, until a better way is found */ for( MODULE* module = aPcb->m_Modules; module; module = module->Next() ) { for( BOARD_ITEM* item = module->GraphicalItems(); item; item = item->Next() ) { if( !item->IsOnLayer( GetLayer() ) && !item->IsOnLayer( Edge_Cuts ) ) continue; if( item->Type() != PCB_MODULE_EDGE_T ) continue; item_boundingbox = item->GetBoundingBox(); if( item_boundingbox.Intersects( zone_boundingbox ) ) { ( (EDGE_MODULE*) item )->TransformShapeWithClearanceToPolygon( aFeatures, zone_clearance, segsPerCircle, correctionFactor ); } } } // Add graphic items (copper texts) and board edges for( BOARD_ITEM* item = aPcb->m_Drawings; item; item = item->Next() ) { if( item->GetLayer() != GetLayer() && item->GetLayer() != Edge_Cuts ) continue; switch( item->Type() ) { case PCB_LINE_T: ( (DRAWSEGMENT*) item )->TransformShapeWithClearanceToPolygon( aFeatures, zone_clearance, segsPerCircle, correctionFactor ); break; case PCB_TEXT_T: ( (TEXTE_PCB*) item )->TransformBoundingBoxWithClearanceToPolygon( aFeatures, zone_clearance ); break; default: break; } } // Add zones outlines having an higher priority and keepout for( int ii = 0; ii < GetBoard()->GetAreaCount(); ii++ ) { ZONE_CONTAINER* zone = GetBoard()->GetArea( ii ); if( zone->GetLayer() != GetLayer() ) continue; if( !zone->GetIsKeepout() && zone->GetPriority() <= GetPriority() ) continue; if( zone->GetIsKeepout() && ! zone->GetDoNotAllowCopperPour() ) continue; // A highter priority zone or keepout area is found: remove this area item_boundingbox = zone->GetBoundingBox(); if( !item_boundingbox.Intersects( zone_boundingbox ) ) continue; // Add the zone outline area. // However if the zone has the same net as the current zone, // do not add any clearance. // the zone will be connected to the current zone, but filled areas // will use different parameters (clearance, thermal shapes ) bool same_net = GetNetCode() == zone->GetNetCode(); bool use_net_clearance = true; int min_clearance = zone_clearance; // Do not forget to make room to draw the thick outlines // of the hole created by the area of the zone to remove int holeclearance = zone->GetClearance() + outline_half_thickness; // The final clearance is obviously the max value of each zone clearance min_clearance = std::max( min_clearance, holeclearance ); if( zone->GetIsKeepout() || same_net ) { // Just take in account the fact the outline has a thickness, so // the actual area to substract is inflated to take in account this fact min_clearance = outline_half_thickness; use_net_clearance = false; } zone->TransformOutlinesShapeWithClearanceToPolygon( aFeatures, min_clearance, use_net_clearance ); } // Remove thermal symbols for( MODULE* module = aPcb->m_Modules; module; module = module->Next() ) { for( D_PAD* pad = module->Pads(); pad != NULL; pad = pad->Next() ) { // Rejects non-standard pads with tht-only thermal reliefs if( GetPadConnection( pad ) == PAD_ZONE_CONN_THT_THERMAL && pad->GetAttribute() != PAD_ATTRIB_STANDARD ) continue; if( GetPadConnection( pad ) != PAD_ZONE_CONN_THERMAL && GetPadConnection( pad ) != PAD_ZONE_CONN_THT_THERMAL ) continue; if( !pad->IsOnLayer( GetLayer() ) ) continue; if( pad->GetNetCode() != GetNetCode() ) continue; item_boundingbox = pad->GetBoundingBox(); int thermalGap = GetThermalReliefGap( pad ); item_boundingbox.Inflate( thermalGap, thermalGap ); if( item_boundingbox.Intersects( zone_boundingbox ) ) { CreateThermalReliefPadPolygon( aFeatures, *pad, thermalGap, GetThermalReliefCopperBridge( pad ), m_ZoneMinThickness, segsPerCircle, correctionFactor, s_thermalRot ); } } } }
int CgptPrioritize(CgptPrioritizeParams *params) { struct drive drive; int priority; int gpt_retval; uint32_t index; uint32_t max_part; int num_root; int i,j; group_list_t *groups; if (params == NULL) return CGPT_FAILED; if (CGPT_OK != DriveOpen(params->drive_name, &drive, 0, O_RDWR)) return CGPT_FAILED; if (GPT_SUCCESS != (gpt_retval = GptSanityCheck(&drive.gpt))) { Error("GptSanityCheck() returned %d: %s\n", gpt_retval, GptError(gpt_retval)); return CGPT_FAILED; } max_part = GetNumberOfEntries(&drive); if (params->set_partition) { if (params->set_partition < 1 || params->set_partition > max_part) { Error("invalid partition number: %d (must be between 1 and %d\n", params->set_partition, max_part); goto bad; } index = params->set_partition - 1; // it must be a kernel if (!IsRoot(&drive, PRIMARY, index) && !IsMarker(&drive, PRIMARY, index)) { Error("partition %d is not a valid root\n", params->set_partition); goto bad; } } // How many kernel partitions do I have? num_root = 0; for (i = 0; i < max_part; i++) { if (IsRoot(&drive, PRIMARY, i) || IsMarker(&drive, PRIMARY, i)) num_root++; } if (num_root) { // Determine the current priority groups groups = NewGroupList(num_root); for (i = 0; i < max_part; i++) { if (!IsRoot(&drive, PRIMARY, i) && !IsMarker(&drive, PRIMARY, i)) continue; priority = GetPriority(&drive, PRIMARY, i); // Is this partition special? if (params->set_partition && (i+1 == params->set_partition)) { params->orig_priority = priority; // remember the original priority if (params->set_friends) AddToGroup(groups, priority, i); // we'll move them all later else AddToGroup(groups, 99, i); // move only this one } else { AddToGroup(groups, priority, i); // just remember } } // If we're including friends, then change the original group priority if (params->set_partition && params->set_friends) { ChangeGroup(groups, params->orig_priority, 99); } // Sorting gives the new order. Now we just need to reassign the // priorities. SortGroups(groups); // We'll never lower anything to zero, so if the last group is priority zero // we can ignore it. i = groups->num_groups; if (groups->group[i-1].priority == 0) groups->num_groups--; // Where do we start? if (params->max_priority) priority = params->max_priority; else priority = groups->num_groups > 15 ? 15 : groups->num_groups; // Figure out what the new values should be for (i=0; i<groups->num_groups; i++) { groups->group[i].priority = priority; if (priority > 1) priority--; } // Now apply the ranking to the GPT for (i=0; i<groups->num_groups; i++) for (j=0; j<groups->group[i].num_parts; j++) SetPriority(&drive, PRIMARY, groups->group[i].part[j], groups->group[i].priority); FreeGroups(groups); } // Write it all out UpdateAllEntries(&drive); return DriveClose(&drive, 1); bad: (void) DriveClose(&drive, 0); return CGPT_FAILED; }
bool ALSound::SearchFreeBuffer(Sound sound, int &channel, bool &bAlreadyLoaded) { int priority = GetPriority(sound); // Seeks a channel used which sound is stopped. for (auto it : mChannels) { if (it.second->IsPlaying()) continue; if (it.second->GetSoundType() != sound) continue; it.second->SetPriority(priority); channel = it.first; bAlreadyLoaded = it.second->IsLoaded(); return true; } // just add a new channel if we dont have any if (mChannels.size() == 0) { Channel *chn = new Channel(); // check if we channel ready to play music, if not report error if (chn->IsReady()) { chn->SetPriority(priority); mChannels[1] = chn; channel = 1; bAlreadyLoaded = false; return true; } delete chn; GetLogger()->Error("Could not open channel to play sound!"); return false; } // Seeks a channel completely free. if (mChannels.size() < 64) { auto it = mChannels.end(); it--; int i = (*it).first; while (++i) { if (mChannels.find(i) == mChannels.end()) { Channel *chn = new Channel(); // check if channel is ready to play music, if not destroy it and seek free one if (chn->IsReady()) { chn->SetPriority(priority); mChannels[++i] = chn; channel = i; bAlreadyLoaded = false; return true; } delete chn; GetLogger()->Warn("Could not open additional channel to play sound!"); } } } int lowerOrEqual = -1; for (auto it : mChannels) { if (it.second->GetPriority() < priority) { GetLogger()->Debug("Sound channel with lower priority will be reused."); channel = it.first; return true; } if (it.second->GetPriority() <= priority) lowerOrEqual = it.first; } if (lowerOrEqual != -1) { channel = lowerOrEqual; GetLogger()->Debug("Sound channel with lower or equal priority will be reused."); return true; } GetLogger()->Warn("Could not find free buffer to use.\n"); return false; }
/* *将中缀表达式转换为后缀表达式 */ Status InfixToPostfix(char *infix,char *postfix) { myStack s; ElemType c,temp; //int index=0,len,i=0,sum=0; InitStack(&s); do { c = *(infix++); if(c >= '0'&& c<= '9' )//如果是数字 { *(postfix++) = c; }else { if((c == '(') || (c == '[') || (c == '{')) { Push(&s,c); }else if((c == ')') || (c == ']') || (c == '}')) { while(1) { Pop(&s,&temp); if(IsEmpty(&s) || (temp == '(')) { break; } *(postfix++) = temp; } } else if((c == '+') || (c == '-') || (c == '*') || (c == '/') || (c == '%') || (c == '^')) { while(1) { if(IsEmpty(&s)) { Push(&s,c); break; }else { GetTopElement(&s,&temp); if(GetPriority(temp) >= GetPriority(c)) { Pop(&s,&temp); *(postfix++) = temp; }else { Push(&s,c); break; } } } }else { printf("%c为非法输入!\n",c); } } }while( *infix != '\n'); //将剩下的输出 while(!IsEmpty(&s)) { Pop(&s,&c); *(postfix++) = c; } DestroyStack(&s); return TRUE; }