Пример #1
0
	bool KL2Map_Base::_InsertJointToBlock(const _Node_Lite * pNode)
	{	PERF_COUNTER(KL2Map_Base__InsertJointToBlock);

		ASSERT_RETURN(pNode, false);
		int_r bx(-1), by(-1);
		GetJointBlockPos(pNode->x, pNode->y, bx, by);
		ASSERT_RETURN(bx >= 0, false);
		ASSERT_RETURN(by >= 0, false);
		return m_L2MapByBlock[bx][by].insert_unique(pNode) > -1;
	}
Пример #2
0
int	SYSTEM_USERS_NUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
{
#ifdef _WINDOWS
	char	counter_path[64];

	zbx_snprintf(counter_path, sizeof(counter_path), "\\%d\\%d", PCI_TERMINAL_SERVICES, PCI_TOTAL_SESSIONS);

	return PERF_COUNTER(cmd, counter_path, flags, result);
#else
	return EXECUTE_INT(cmd, "who | wc -l", flags, result);
#endif
}
Пример #3
0
	void KL2Map_Base::ComputePtListWithDistance(int_r fromx, int_r fromy, __NodeList_ByDistance& ptList)
	{	PERF_COUNTER(KL2Map_Base_ComputePtListWithDistance);

		ASSERT(mpSettings && mpSettings->mMapSize >= mpSettings->mBlockSize);
		ptList.clear();
		int_r blx, bhx, bly, bhy, bx, by;
		GetJointBlockPos(fromx, fromy, bx, by);
		// 窗口使用附近3x3个区域
		blx = bx - 1;
		bhx = bx + 1;
		bly = by - 1;
		bhy = by + 1;

		//如果窗口延伸超出当前512将被剪裁。使用大地图的时候可以考虑去掉这个限制。
		int_r nRate = mpSettings->mMapSize / mpSettings->mBlockSize;
		ASSERT(0 != nRate);
		bx /= nRate;
		by /= nRate;
		if (blx / nRate != bx)
		{
			blx++;
		}
		if (bhx / nRate != bx)
		{
			bhx--;
		}
		if (bly / nRate != by)
		{
			bly++;
		}
		if (bhy / nRate != by)
		{
			bhy--;
		}

		__DistanceInfo di;
		for (bx = blx; bx <= bhx; ++bx)
		{
			for (by = bly; by <= bhy; ++by)
			{
				int_r nSize = m_L2MapByBlock[bx][by].size();
				for (int_r i = 0; i < nSize; ++i)
				{
					int_r x = m_L2MapByBlock[bx][by][i]->x;
					int_r y = m_L2MapByBlock[bx][by][i]->y;
					di.first = Find(x, y);
					ASSERT(di.first);
					di.second = sqrtf(Distance2D(fromx,fromy,x,y));
					ptList.insert(di);
				}
			}
		}
	}
Пример #4
0
	void KL2Map_Base::RecomputeJointBlock()
	{	PERF_COUNTER(KL2Map_Base_RecomputeJointBlock);

		m_L2MapByBlock.clear();
		int_r nSize = mPosArray.size();
		bool bRet = false;
		for(int_r i = 0; i < nSize; ++i)
		{
			bRet = _InsertJointToBlock( mPosArray[i] );
			ASSERT(bRet);
		}
	}
Пример #5
0
	KL2Map_Base::KL2Map_Base()
	{	PERF_COUNTER(KL2Map_Base_KL2Map_Base);

		m_pFinder = NULL;
		offsetX = 0;
		offsetY = 0;
		mPosArray.clear();
		mIDArray.clear();
		mPosMap.clear();
		mIDMap.clear();
		mRoads.clear();
		m_L2MapByBlock.clear();
	}
Пример #6
0
	bool KL2Map_Base::CreateOneRoad(int_r nID, const _Node_Lite * pBegin, const _Node_Lite * pEnd, bool bUnidirectional)
	{	PERF_COUNTER(KL2Map_Base_CreateOneRoad);

		mRoads[nID].m_Cost = sqrtf(Distance2D(pBegin->x, pBegin->y, pEnd->x, pEnd->y));
		mRoads[nID].push_back(pBegin);
		mRoads[nID].push_back(pEnd);
		mIDMap[pBegin->id][pEnd->id] = nID;
		if(!bUnidirectional)
		{
			mIDMap[pEnd->id][pBegin->id] = nID;
		}
		return true;
	}
Пример #7
0
	void KL2Map_Base::GetJointBlockPos(int_r x, int_r y, int_r& bx, int_r& by) const
	{	PERF_COUNTER(KL2Map_Base_GetJointBlockPos);

		if(mpSettings)
		{
			bx = x / mpSettings->mBlockSize;
			by = y / mpSettings->mBlockSize;
		}
		else
		{
			bx = x;
			by = y;
		}
	}
Пример #8
0
	bool KL2Map_Base::FindPath(int_r from, int_r to, __Nodes& st, VALUE_T& cost)
	{	PERF_COUNTER(KL2Map_Base_FindPath);

		cost = 0;
		st.clear();
		if (from == to)
		{
			const _Node_Lite * p = Find(from);
			if (p)
			{
				push_point(st, p);
			}
			return st.size() != 0;
		}

		JG_C::DynArray<int_r> nodeIDs;
		if (m_pFinder)
		{
			if (m_pFinder->GetPath(from, to, nodeIDs, cost) > 0)
			{
				int_r d1 = nodeIDs[0];
				int_r d2 = 0;
				for (int_r i = 1; i < nodeIDs.size(); i++)
				{
					d2 = nodeIDs[i];
					const __OneRoad * pr = GetRoad(d1, d2);
					if ( pr != NULL )
					{
						//正向填充
						for (int_r j = 0; j < pr->m_Road.size(); j++)
						{
							if (st.size() > 0 && st[st.size() - 1] == pr->m_Road[j])
							{
								continue;
							}
							st.push_back(pr->m_Road[j]);
						}
					}
					d1 = d2;
				}
				return true;
			}
			else
			{
				return false;
			}
		}
		return false;
	}
Пример #9
0
	bool KL2Map_Base::AddOneJoint(const _Node_Lite * pNode)
	{	PERF_COUNTER(KL2Map_Base_AddOneJoint);

		ASSERT(pNode->id > 0);
		if( Find(pNode->x, pNode->y) )
			return false;
		if( Find(pNode->id) )
			return false;
		int_r pos = mPosArray.insert_unique(pNode);
		ASSERT(pos > -1);
		pos = mIDArray.insert_unique(pNode);
		ASSERT(pos > -1);
		bool bRet = _InsertJointToBlock(pNode);
		ASSERT(bRet);
		return bRet;
	}
Пример #10
0
int	SYSTEM_USERS_NUM(AGENT_REQUEST *request, AGENT_RESULT *result)
{
#ifdef _WINDOWS
	char		counter_path[64];
	AGENT_REQUEST	request_tmp;
	int		ret;

	zbx_snprintf(counter_path, sizeof(counter_path), "\\%d\\%d", PCI_TERMINAL_SERVICES, PCI_TOTAL_SESSIONS);

	request_tmp.nparam = 1;
	request_tmp.params = zbx_malloc(NULL, request_tmp.nparam * sizeof(char *));
	request_tmp.params[0] = counter_path;

	ret = PERF_COUNTER(&request_tmp, result);

	zbx_free(request_tmp.params);

	return ret;
#else
	return EXECUTE_INT("who | wc -l", result);
#endif
}
Пример #11
0
	void KL2Map_Base::OffsetMap(int_r x, int_r y)
	{	PERF_COUNTER(KL2Map_Base_OffsetMap);

		if (x == offsetX && y == offsetY)
		{
			return;
		}
		int_r ox = x - offsetX;
		int_r oy = y - offsetY;
		offsetX = x;
		offsetY = y;
		x = ox;
		y = oy;
		int_r i;
		for (i = 0; i < mPosArray.size(); i++)
		{
			(const_cast<_Node_Lite *>(mPosArray[i]))->x += x;
			(const_cast<_Node_Lite *>(mPosArray[i]))->y += y;
		}
		
		//int_r nSize1 = mIDMap.size();
		//int_r nSize2 = 0;
		//int_r nKey = 0;
		//for (int_r i = 0; i < nSize1; ++i)
		//{
		//	nSize2 = mIDMap[i].size();
		//	for (int_r j = 0; j < nSize2; ++j)
		//	{
		//		nKey = mIDMap[i][j];
		//		for (i = 0; i < mRoads[nKey].m_Road.size(); i++)
		//		{
		//			(const_cast<_Node_Lite *>(mRoads[nKey].m_Road[i]))->x += x;
		//			(const_cast<_Node_Lite *>(mRoads[nKey].m_Road[i]))->y += y;
		//		}
		//	}
		//}
		RecomputeJointBlock();
	}