Пример #1
0
// This is called from main DoCalculations each time, only when running a real task
void InSector(NMEA_INFO *Basic, DERIVED_INFO *Calculated)
{
  static int LastStartSector = -1;

  if (ActiveWayPoint<0) return;
  LockTaskData();

// Paragliders task system
// Case A: start entering the sector/cylinder
//		you must be outside sector when gate is open.
//		you are warned that you are already inside sector before the gate is open, when gate is opening in <10 minutes
//		task restart is manual
// Case B: start exiting the sector

  // by default, we are not in the sector
  Calculated->IsInSector = false;

  if(ActiveWayPoint == 0) {
	CheckStart(Basic, Calculated, &LastStartSector);
  } else {
	if(IsFinalWaypoint()) {
		LastStartSector = -1;
		AddAATPoint(Basic, Calculated, ActiveWayPoint-1);
		CheckFinish(Basic, Calculated);
	} else {
		if (!UseGates()) CheckRestart(Basic, Calculated, &LastStartSector); // 100507
		if (ActiveWayPoint>0) {
			CheckInSector(Basic, Calculated);
			LastStartSector = -1;
		}
	}
  }                   
  UnlockTaskData();
}
Пример #2
0
	RgAnalyser::RgAnalyser (const QStringList& paths, QObject *parent)
	: QObject { parent }
	, Paths_ { paths }
#if GST_VERSION_MAJOR < 1
	, Pipeline_ (gst_element_factory_make ("playbin2", nullptr))
#else
	, Pipeline_ (gst_element_factory_make ("playbin", nullptr))
#endif
	, SinkBin_ { gst_bin_new (nullptr) }
	, AConvert_ { gst_element_factory_make ("audioconvert", nullptr) }
	, AResample_ { gst_element_factory_make ("audioresample", nullptr) }
	, RGAnalysis_ { gst_element_factory_make ("rganalysis", nullptr) }
	, Fakesink_ { gst_element_factory_make ("fakesink", nullptr) }
	, PopThread_ { new LightPopThread { gst_pipeline_get_bus (GST_PIPELINE (Pipeline_)), this } }
	{
		qRegisterMetaType<GstMessage_ptr> ("GstMessage_ptr");

		gst_bin_add_many (GST_BIN (SinkBin_),
				AConvert_, AResample_, RGAnalysis_, Fakesink_, nullptr);
		gst_element_link_many (AConvert_, AResample_, RGAnalysis_, Fakesink_, nullptr);

		auto pad = gst_element_get_static_pad (AConvert_, "sink");
		auto ghostPad = gst_ghost_pad_new ("sink", pad);
		gst_pad_set_active (ghostPad, TRUE);
		gst_element_add_pad (SinkBin_, ghostPad);
		gst_object_unref (pad);

		g_object_set (GST_OBJECT (RGAnalysis_), "num-tracks", paths.size (), nullptr);
		g_object_set (GST_OBJECT (Pipeline_), "audio-sink", SinkBin_, nullptr);

		CheckFinish ();

		PopThread_->start ();
	}
//Function used to tie together whole program and allow us to use a single function to invoke an A Star search.
void PathFind(bool &goalReached, deque <unique_ptr < SCoords > > &openList, deque <unique_ptr < SCoords > > &closedList, SCoords mapEnd, SCoords &north, SCoords &east, SCoords &south, SCoords &west
	, int mapArray[10][10], IModel* mapSquares[10][10], IMesh* squareMesh, int newCost, int existingCost, string visitedNodeSkin, string openListNodeSkin, bool &validNode)
{
	unique_ptr<SCoords> currentNode(new SCoords);
	if (!goalReached || openList.empty())
	{
		currentNode.reset(new SCoords);//Reset the current node every loop because we move current node onto closed list at the end of every loop.
		currentNode = move(openList.front());//We then set current node to the first value on open list and pop the value from open list.
		openList.pop_front();
		mapSquares[currentNode->y][currentNode->x]->SetSkin(visitedNodeSkin);
		if (CheckFinish(currentNode.get(), mapEnd.x, mapEnd.y))//Check if the end goal has been reached. If it has then we exit the loop after dispalying an end message.
		{
			openList.push_back(move(currentNode));//We then push the final node back onto open list so we can move through it's parent chain.
			goalReached = true;
			return;
		}
		//If the current node isn't the end goal then we generate new nodes.
		else
		{
			GenerateNodes(north, east, south, west, currentNode.get());
			//Then we check if the nodes have already been visited by checking openlist, if they haven't then we insert them. 
			CalculatePath(currentNode.get(), mapArray, newCost, existingCost, north, mapEnd, openList, closedList, validNode);
			//If the node is a valid node,i.e. the node isn't a wall then a skin is applied to the square to indicate that it is a viable node.
			if (validNode)
			{
				mapSquares[north.y][north.x]->SetSkin(openListNodeSkin);
			}
			validNode = false;
			CalculatePath(currentNode.get(), mapArray, newCost, existingCost, east, mapEnd, openList, closedList, validNode);
			if (validNode)
			{
				mapSquares[east.y][east.x]->SetSkin(openListNodeSkin);
			}
			validNode = false;
			CalculatePath(currentNode.get(), mapArray, newCost, existingCost, south, mapEnd, openList, closedList, validNode);
			if (validNode)
			{
				mapSquares[south.y][south.x]->SetSkin(openListNodeSkin);
			}
			validNode = false;
			CalculatePath(currentNode.get(), mapArray, newCost, existingCost, west, mapEnd, openList, closedList, validNode);
			if (validNode)
			{
				mapSquares[west.y][west.x]->SetSkin(openListNodeSkin);
			}
			validNode = false;
			closedList.push_back(move(currentNode));
		}
		//The list is then sorted based on score from lowest to highest.
		sort(openList.begin(), openList.end(), CompareCoords);
	}
}
Пример #4
0
BOOL CGameCtrler::MouseClick(CPoint ptInPicWnd)
{
	m_iClickCount++;
	if (m_iClickCount==1)
	{
		m_ptCFirstClick = ptInPicWnd;
	}
	else if (m_iClickCount==2)
	{
		SwapBlock(ptInPicWnd);
		ResetClickCount(); // µã»÷Á½´Îºó¹éÁã
		m_ptCFirstClick = CPoint(-1,-1);
	}
	return CheckFinish();
}
Пример #5
0
static void trace(void *HPs[], int len, struct localAlloc *local){
	int counter=0;
	const unsigned long localSweep=MAKE_SC(0, local->localVer);
	const unsigned long *const globalSweepPtr=&local->global->sweep_counter;
	void **markstack=local->markstack;
	traceRoots(local, &counter);

	for(int i=0; i<len; ++i){
		assert(HPs[i]!=NULL && CLEAR_PTR(HPs[i])==HPs[i]);
		markstack[++counter]=HPs[i];
	}
	traceMarkstack(markstack, counter, globalSweepPtr, localSweep, local);
	markstack[0]=(void*)((long)markstack[0]|1);//I finished.
	while(!CheckFinish(local, markstack, &counter)){
		traceMarkstack(markstack, counter, globalSweepPtr, localSweep, local);
		markstack[0]=(void*)((long)markstack[0]|1);//I finished.
	}
	//move sweep counter to current phase
	resetSweepCounter(local);
}
Пример #6
0
	void RgAnalyser::HandleErrorMsg (GstMessage *msg)
	{
		GError *gerror = nullptr;
		gchar *debug = nullptr;
		gst_message_parse_error (msg, &gerror, &debug);

		const auto& msgStr = QString::fromUtf8 (gerror->message);
		const auto& debugStr = QString::fromUtf8 (debug);

		const auto code = gerror->code;
		const auto domain = gerror->domain;

		g_error_free (gerror);
		g_free (debug);

		qWarning () << Q_FUNC_INFO
				<< domain
				<< code
				<< msgStr
				<< debugStr;


		if (IsDraining_)
			return;

		IsDraining_ = true;
		const auto bus = gst_pipeline_get_bus (GST_PIPELINE (Pipeline_));
		while (const auto msg = gst_bus_timed_pop (bus, 0.01 * GST_SECOND))
			handleMessage (std::shared_ptr<GstMessage> (msg, gst_message_unref));
		IsDraining_ = false;

		gst_element_set_state (Pipeline_, GST_STATE_NULL);
		PopThread_->Resume ();

		const auto trackInfoPos = std::find_if (Result_.Tracks_.begin (), Result_.Tracks_.end (),
				[this] (const TrackRgResult& info) { return info.TrackPath_ == CurrentPath_; });
		if (trackInfoPos == Result_.Tracks_.end ())
			Result_.Tracks_.append ({ CurrentPath_, 0, 0 });

		CheckFinish ();
	}
Пример #7
0
  void LocalMapping::RunClient() {

    mbFinished = false;

    while(1) {
      // Tracking will see that Local Mapping is busy
      SetAcceptKeyFrames(false);

      // Check if there are keyframes in the queue
      if(CheckNewKeyFrames()) {
        // Get Communicator Mutex -> Comm cannot publish. Assure no publishing whilst changing data
        //            if(mpComm->mbStrictLock) unique_lock<mutex> lockComm(mpComm->mMutexForMapping);
        if(mVerboseMode == -9) {
          cout << "xxx Mapping --> Lock Mapping xxx" << endl;
        }

        if(mVerboseMode == -9) {
          cout << "LockSleep: " << mpCC->mLockSleep << endl;
        }

        if(mpComm->mbStrictLock) while(!mpCC->LockMapping()) {
            usleep(mpCC->mLockSleep);
          }

        if(mVerboseMode == -9) {
          cout << "xxx Mapping --> Mapping Locked xxx" << endl;
        }

        // BoW conversion and insertion in Map
        ProcessNewKeyFrame();

        // Check recent MapPoints
        MapPointCulling();

        // Triangulate new MapPoints
        CreateNewMapPoints();

        if(!CheckNewKeyFrames()) {
          // Find more matches in neighbor keyframes and fuse point duplications
          SearchInNeighbors();
        }

        mbAbortBA = false;

        if(!CheckNewKeyFrames() && !stopRequested()) {
          // Local BA
          if(mpMap->KeyFramesInMap() > 2) {
            Optimizer::LocalBundleAdjustmentClient(mpCurrentKeyFrame, &mbAbortBA, mpMap, mpComm, mClientId);
          }

          //                // Check redundant local Keyframes
          //                KeyFrameCulling();
        }

        if(mpComm->mbStrictLock) {
          mpCC->UnLockMapping();
        }

      } else if(Stop()) {
        // Safe area to stop
        while(isStopped() && !CheckFinish()) {
          usleep(mMappingRate);
        }

        if(CheckFinish()) {
          break;
        }
      }

      ResetIfRequested();

      // Tracking will see that Local Mapping is busy
      SetAcceptKeyFrames(true);

      if(CheckFinish()) {
        break;
      }

      usleep(mMappingRate);
    }

    SetFinish();
  }
Пример #8
0
	void RgAnalyser::HandleEosMsg (GstMessage*)
	{
		CheckFinish ();
	}
Пример #9
0
void CUploadTask::Run()
{
	m_Item.ullOffset=0;
	if (m_Item.ullFilesize==0)
	{
		string content="";
		CURLcode ret=COssApi::AddObject(m_Item.strHost,m_Item.strBucket,m_Item.strObject,m_Item.ullFilesize,this,NULL,(culfunc)curl_header,content);
		int httpcode=ParesHeaderCode(m_strHeader);
		if (httpcode==200)
		{
			Finish();
			goto END;
		}
		if (httpcode>0)
			TaskError(httpcode,_T("http code"));
		else
			TaskError(ret,_T("curl error"));
		goto END;
	}
	m_UnFinish.InsertPair(0,m_Item.ullFilesize-1);
	if (CheckMultipart())
	{
		if (m_Item.strUploadId==_T(""))
		{
			COssInitiateMultipartUploadRet ret;
			if(COssApi::InitiateMultipartUploadObject(m_Item.strHost,m_Item.strBucket,m_Item.strObject,ret))
			{
				m_Item.strUploadId=ret.m_strUploadId;
				GetNetwork()->m_TransDb.Update_UploadUploadId(m_Item.strPathhash,m_Item.strUploadId);
			}
			else
			{
				TaskError(TRANSERROR_OSSERROR,ret.m_strCode);
				goto END;
			}
		}
		if (!CreateMultipartFile())
		{
			TaskError(TRANSERROR_CREATEMULTIPARTERROR,wstring(GetSkinInfo()->GetString(_T("prompt"),_T("CreateFileInfoError"))));
			goto END;
		}
	}
	m_ullStarttime=CTime::GetCurrentTime().GetTime();
	m_ullRuntime=m_ullStarttime;
	while(true)
	{
		if (m_bStop)
			goto END;
		if (CheckFinish())
		{
			m_ullTranssize=0;
			if (m_Item.strUploadId!=L"")
			{
				COssRet ret;
				if(!COssApi::CompleteMultipartUpload(m_Item.strHost,m_Item.strBucket,m_Item.strObject,m_Item.strUploadId,m_PartList,ret))
				{
					TaskError(TRANSERROR_OSSERROR,ret.m_strCode);//zhengÓеĴíÎóÓ¦¸Ãɾ³ýid
					goto END;
				}
			}
			Finish();
			goto END;
		}
		int nNum=GetPeerNum();
		if (nNum>=GetNetwork()->m_UManager.m_nPeerMax)
		{
			Sleep(1);
			continue;
		}
		ULONGLONG ullPos,ullSize;
		ullPos=ullSize=0;
		m_csFileLock.Lock();
		int nIndex=GetUploadIndex(ullPos,ullSize);
		m_csFileLock.Unlock();
		if (nIndex<0)
		{
			Sleep(1000);
			continue;
		}
		m_csLock.Lock();
		nNum=m_listPeer.size();
		m_csLock.Unlock();
		if (nNum<GetNetwork()->m_UManager.m_nPeerMax)
		{
			CUploadPeer * peer =new CUploadPeer;
			peer->Init(this,m_Item.strHost,m_Item.strBucket,m_Item.strObject);
			if (peer->OpenFile(m_Item.strUploadId,m_Item.strFullpath))
			{
				m_csFileLock.Lock();
				m_UnFinish.RemovePairs(ullPos,ullPos+ullSize-1);
				m_csFileLock.Unlock();
				m_csLock.Lock();
				m_listPeer.push_back(peer);
				m_csLock.Unlock();
				peer->StartUpload(nIndex,ullPos,ullSize);
				GetNetwork()->m_ThreadPool.AddTask(peer);
			}
			else
			{
				int a=GetLastError();
				delete peer;
				if (m_Item.strUploadId==_T(""))
				{
					TaskError(TRANSERROR_OPENFILE,wstring(slnhelper::GetLastErrorMessage(a)));
					goto END;
				}
			}
		}
		else
		{
			bool bHave=false;
			m_csLock.Lock();
			for (int i=0;i<m_listPeer.size();i++)
			{
				CUploadPeer * peer =(CUploadPeer*)m_listPeer[i];
				if (peer->IsIdle())
				{
					m_csFileLock.Lock();
					m_UnFinish.RemovePairs(ullPos,ullPos+ullSize-1);
					m_csFileLock.Unlock();
					peer->StartUpload(nIndex,ullPos,ullSize);
					GetNetwork()->m_ThreadPool.AddTask(peer);
					bHave=true;
					break;
				}
			}
			m_csLock.Unlock();
			if (!bHave)
				Sleep(10);
		}
	}
END:
	if (m_bDelete&&CheckMultipart())
	{
		if (m_Item.strUploadId!=L"")
		{
			COssRet ret;
			COssApi::AbortMultipartUpload(m_Item.strHost,m_Item.strBucket,m_Item.strObject,m_Item.strUploadId,ret);
		}
	}
	if (m_entOut)
		m_entOut->SetEvent();
	m_Item.nStatus=TRANSTASK_REMOVE;
}